Skip to content

Instantly share code, notes, and snippets.

@agross
Created December 22, 2016 15:24
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 agross/6a1af5c0de75b274afcb0267270abe5b to your computer and use it in GitHub Desktop.
Save agross/6a1af5c0de75b274afcb0267270abe5b to your computer and use it in GitHub Desktop.
git cherry-pick adds more lines than expected
#!/bin/bash
git init
echo 1 > file
# This is the magic line.
echo * merge=union > .gitattributes
git add .
git commit -m 1
git checkout -b test
echo 2 >> file
git commit -am 2
echo 3 >> file
git commit -am 3
git checkout -
# Without merge=union, this results in a conflict.
git cherry-pick test
@agross
Copy link
Author

agross commented Dec 22, 2016

The resulting graph looks like this:

  master
    ↓
1 - 3'
 \
   2 - 3
       ↑
      test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment