git backout master, push to branch, to go into master at later date
How would I go about:
1) Reverting changes pushed out to master (remote)
2) Moving 开发者_运维百科those changes to a separate branch 3) Move those changes back into master at a later timeFirst do 2), but only if you really need the branch.
git branch changes
Then do 1) using git revert
.
Finally, redo the changes by reverting the revert commits.
Assuming you have already cloned the remote repo and you're on the master
branch, you could do the following:
Do the second thing first:
git branch new-branch
Then revert changes on master:
git revert <commit-id-you-want-reverted>
(repeat for each bad commit)git push origin HEAD:master
Later, cherry-pick them back:
git cherry-pick <commits-from-new-branch>; git push origin HEAD:master
I think that'll work, but I haven't tried it myself. YMMV. I think simply pulling the changes back (without cherry-picking) won't work because they'll have the original commit IDs and git might know that it doesn't need to pull them in...then again, maybe with a new HEAD it will work. Try it and see :)
精彩评论