how to commit changes to new branch
I just made changes to a branch. My question is, how can I commit the changes to the other branch?
I am trying to use:
git checkout "the commmit to the changed branch" -b "the other branch"
However, I don't think this is the right thing to do, because in this case I'm creating a new branch instead of committing the changes to "the other branch".
Should I use the following command instead?
git merge "the other branch"
Thank you.
git checkout -b your-new-branch
git add <files>
git commit -m <message>
First, checkout your new branch. Then add all the files you want to commit to staging. Lastly, commit all the files you just added. You might want to do a git push origin your-new-branch
afterward so your changes show up on the remote.
If I understand right, you've made a commit to changed_branch
and you want to copy that commit to other_branch
? Easy:
git checkout other_branch
git cherry-pick changed_branch
You can use stash your work, create a new branch, then pop your stash changes:
git stash
git checkout -b branch_name
git stash pop
It will be as if you had made those changes after creating the new branch.
链接地址: http://www.djcxy.com/p/23592.html下一篇: 如何提交对新分支的更改