How to rebase all the commits from the beginning

后端 未结 5 870
北荒
北荒 2021-01-31 07:12

So I\'m migrating from svn (code.google.com) to git(github).

I\'ve imported my project from the svn repo, and it imported all the commit history along way. I\'m not real

5条回答
  •  逝去的感伤
    2021-01-31 07:52

    Jefromi's answer will work, but if you want to keep your existing repo configuration, or even leave around the commits just in case, you could do the following:

    git checkout master

    git branch backup optionally leave another branch here in case you want to keep your history.

    git reset --soft $SHA_OF_INIT_COMMIT this will update what HEAD is pointing to but leave your index and working directory in their current state. You can get the SHA with git log --pretty=format:%h --reverse | head -n 1, and make this one step with git reset --soft $(git log --pretty=format:%h --reverse | head -n 1)

    git commit --amend change your initial commit to point to the current state of your repo.

提交回复
热议问题