Git: Can I commit my working directory to a new branch without committing it to a current branch?

前端 未结 2 1303
旧巷少年郎
旧巷少年郎 2021-01-01 17:23

I am working on a project, and had all of my tests passing on the master branch. I then made some changes, and when everything started failing, I realized that maybe I shou

相关标签:
2条回答
  • 2021-01-01 17:43

    You can stash your current changes (git stash), switch to the new branch and then apply the changes to the new branch using

    git stash pop
    
    0 讨论(0)
  • 2021-01-01 17:47

    Yes, just create the new branch and check it out:

    $ git checkout -b new-branch
    

    Then commit any changes you have. They'll be applied to the new, checked-out branch.

    0 讨论(0)
提交回复
热议问题