美文网首页Git
Git move uncommitted changes to

Git move uncommitted changes to

作者: JaedenKil | 来源:发表于2018-08-31 15:55 被阅读7次

For instance, if you're working on a dev branch, make some changes, before you make any commits, you decide these changes should stay on a new branch.

git status

modified: XXX
modified: YYY

Say you'd rather create a new branch newFeature.

$ git checkout -b newFeature
Switched to a new branch 'newFeature'
M       XXX
M       YYY
git status

modified: XXX
modified: YYY

Now on branch newFeature just do commit and push:

git add XXX YYY
git commit -m "Some Message"
git push --set-upstream origin newFeature

And when you turn back to dev, you'll find the uncommitted changes are now gone in dev, and you get all them in newFeature.

$ git status
On branch dev
Your branch is up to date with 'origin/dev'.

Alternatively:

You can just commit in dev, and then do git cherry-pick.

相关文章

网友评论

    本文标题:Git move uncommitted changes to

    本文链接:https://www.haomeiwen.com/subject/pnaswftx.html