Skip to content

Instantly share code, notes, and snippets.

@martinholub
Created June 8, 2020 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinholub/beae90c5badb2d603898d0810e3c8c56 to your computer and use it in GitHub Desktop.
Save martinholub/beae90c5badb2d603898d0810e3c8c56 to your computer and use it in GitHub Desktop.
Merge git branches
# https://stackoverflow.com/questions/449541/how-to-selectively-merge-or-pick-changes-from-another-branch-in-git
# merge branch SOURCE to DETINATION
git checkout DESTINATION
git merge --no-ff --no-commit SOURCE
# inspect and solve potential conflicts
git status
git diff --cached file1
# can change fileX locally, save and commit it if desired
# if you want to keep local (DESTINATION) version of fileX:
git checkout HEAD fileX
# if you want ONLY the SOURCE version of fileX
git checkout SOURCE fileX
# finally commit, add message.
git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment