I already pushed a commit to a remote branch. There is any way to change that commit pushed to another remote branch.
git push <remote> <branch>
can I use the cherry pick for copying the commit to another branch?
I already pushed a commit to a remote branch. There is any way to change that commit pushed to another remote branch.
git push <remote> <branch>
can I use the cherry pick for copying the commit to another branch?
If you really pushed to the wrong remote branch, then you probably have to first undo that push, at least logically, and then do a second push to the correct branch. So something like this:
# undo first commit to wrong branch2
git checkout branch2
git pull origin branch2
git revert <SHA-1 of commit from branch1>
git push origin branch2
# now push to correct branch
git checkout branch1
git push origin branch1
I used git revert
to undo your unwanted commit to branch2
, assuming that this branch is already publicly shared. Reverting a commit is the safe way to proceed in this situation.