Last active
May 29, 2023 09:20
-
-
Save b-b3rn4rd/3e271b111b2fb92bffa2 to your computer and use it in GitHub Desktop.
Moving pushed commit from one branch to another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// moving 71b8026 from features/project-part-2 to features/project-part-1 | |
git checkout features/project-part-2 | |
git revert 71b8026 | |
// for sanity check can run git diff to between branched for particular file(s) | |
git difftool features/project-part-2..features/project-part-1 -- ./website/app/controllers/ExampleController.php | |
git push origin features/project-part-2 | |
git checkout features/project-part-1 | |
git cherry-pick 71b8026 | |
git push origin features/project-part-1 | |
For removing commit form old branch without leaving a "revert" commit You can also:
git checkout features/project-part-2
git rebase -i HEAD~X
git push -f
NOTE:
X stands for number of commits to commit You want to remove.
Select pick for good commits and drop for commits You want to remove
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!