Skip to content

Instantly share code, notes, and snippets.

@b-b3rn4rd
Last active May 29, 2023 09:20
Show Gist options
  • Save b-b3rn4rd/3e271b111b2fb92bffa2 to your computer and use it in GitHub Desktop.
Save b-b3rn4rd/3e271b111b2fb92bffa2 to your computer and use it in GitHub Desktop.
Moving pushed commit from one branch to another
// 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
@ganezdragon
Copy link

thank you :)

@deborah-ufw
Copy link

thank you!

@Tracer1337
Copy link

👍

@thayeylolu
Copy link

Thank you. I found this helpful

@bluelhf
Copy link

bluelhf commented Apr 8, 2021

Thanks!

@PatrykKarpinski
Copy link

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