From 9080f65f0919adf735ef1cbb23a5307242cb3639 Mon Sep 17 00:00:00 2001 From: Peter Mekhaeil <4616064+petermekhaeil@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:07:00 +0800 Subject: [PATCH] Create git-replace-repo-content.md --- learnings/git-replace-repo-content.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 learnings/git-replace-repo-content.md diff --git a/learnings/git-replace-repo-content.md b/learnings/git-replace-repo-content.md new file mode 100644 index 0000000..bbd7198 --- /dev/null +++ b/learnings/git-replace-repo-content.md @@ -0,0 +1,19 @@ +# Replace a Git Repository with a New One + +Sometimes you need to reset a remote Git repository while keeping your local history intact. Here's how: + +**1. Add the Remote:** +```bash +git remote add origin +``` + +Links your local repo to the remote. + +**2. Force Push to Overwrite Remote History:** +```bash +git push --force --set-upstream origin main +``` + +Replaces the remote history with your local history. + +