Reputation: 29120
I have a git repo with public master
and develop
branches. I committed to master
when I should have committed to develop
. I understand that I can move the commits from master
to develop
with the following commands
git checkout develop
git cherry-pick 0123455678 # whatever the hash is I want to move
git checkout master
git rebase -i HEAD~2
git push -f
But this conflicts with what I understand about rebasing, specifically
Do not rebase commits that you have pushed to a public repository.
http://git-scm.com/book/en/Git-Branching-Rebasing#The-Perils-of-Rebasing
Other developers will have pulled both of these branches, so how can I make sure that they are up to date with the rewritten history?
Upvotes: 1
Views: 57
Reputation: 30035
You should probably add the commits to the correct branch and then revert them in master. Revert just adds a new commit to master which undoes the previous wrong changes. It might look a bit messy in the history but it doesn't break anything for anyone who already has pulled those updates.
Upvotes: 2