Creating git branch after many commits

后端 未结 1 1809
北海茫月
北海茫月 2021-02-02 06:46

I have a repo on GitHub with a single branch master that I\'ve been working on in my local repo. At some point I stopped pushing commits back up to master on GitHu

相关标签:
1条回答
  • 2021-02-02 07:05

    on master:

    git checkout -b newbranch or as suggested below, simply do a git branch newbranch to create the new branch without switching to it.

    This will create a branch that is at your current commit at master. Once done:

    git checkout master

    followed by:

    git reset --hard <commit_hash>

    Where <commit_hash> should be replaced by the commit ID you want master rolled back to.

    Now you can switch to your new branch and push it out to the remote.

    git checkout newbranch
    git push origin newbranch
    
    0 讨论(0)
提交回复
热议问题