You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Transferring a GIT repo to new GIT repo with fragmented history
suppose you have a GIT repo with a particular point in commit history before which you want to avoid permanently
with this approach you'll have a new repo with all history intact post that commit .
no links or cache issue what so ever with the old repo .
Identify the hash of the commit you want to be the new starting point (the first commit to keep). Let's call this .
git log --oneline
Create a new, parentless commit (a "root commit") with the exact same content as the commit you want to keep. This command outputs the new commit's hash (let's call it ).
# Change the remote origin URL
git remote set-url origin <URL_of_your_new_github_repo># Verify the new remote URL
git remote -v
# Force push the filtered history to the new repository
git push --force origin main
Force-push the new history to your remote repository to overwrite the old history.