开发者

Git: Howto move changes since last commit to a new branch

开发者 https://www.devze.com 2023-01-06 16:09 出处:网络
开发者_JAVA技巧I have been working on a branch which we can call \"A\". I just realized that the code I have added since I last committed should rather be in a specific (experimental) branch, but not
开发者_JAVA技巧

I have been working on a branch which we can call "A". I just realized that the code I have added since I last committed should rather be in a specific (experimental) branch, but not in "A". How can I commit the changes to a new branch and leave branch "A" as it was when I last committed?


If the changes are staged or your working directory, you can simply checkout into a new branch like so:

git checkout -b branch_name

You can then commit directly into the new branch.


git stash
git checkout branch-A
git stash pop
0

精彩评论

暂无评论...
验证码 换一张
取 消