Skip to content

Instantly share code, notes, and snippets.

@lukaseder
Created September 14, 2021 17:57
Show Gist options
  • Save lukaseder/8878c0f96a887c5706c51bd1ad883111 to your computer and use it in GitHub Desktop.
Save lukaseder/8878c0f96a887c5706c51bd1ad883111 to your computer and use it in GitHub Desktop.
Cherry picking and merging shouldn't produce conflicts per se
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ ll
total 1
-rw-r--r-- 1 lukas 197609 12 Sep 14 19:50 test.txt
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ cat test.txt
a
b
c
d
e
f
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git init
Initialized empty Git repository in C:/Users/lukas/test/.git/
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git add .
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git commit -m "init"
[main (root-commit) c80048e] init
1 file changed, 6 insertions(+)
create mode 100644 test.txt
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git checkout -b b
Switched to a new branch 'b'
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ echo "g" >> test.txt
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git commit -am "g"
[b f478ad6] g
1 file changed, 1 insertion(+)
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ sed -i '4d' test.txt
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git commit -am "-d"
[b dca1b82] -d
1 file changed, 1 deletion(-)
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ cat test.txt
a
b
c
e
f
g
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git log
commit dca1b8204c809fb0201d6e01ced10163aec4dc41 (HEAD -> b)
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:41 2021 +0200
-d
commit f478ad6965ed8c824c7ac75a3cb35135bc5220d3
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:24 2021 +0200
g
commit c80048e572b677b9612ee8f1950c5cbf77e24eed (main)
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:51:07 2021 +0200
init
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git checkout main
Switched to branch 'main'
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git cherry-pick dca1b8
Auto-merging test.txt
[main ac038b0] -d
Date: Tue Sep 14 19:52:41 2021 +0200
1 file changed, 1 deletion(-)
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git log
commit ac038b0e5d9a817ba381a2450514b0abf07e5ff6 (HEAD -> main)
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:41 2021 +0200
-d
commit c80048e572b677b9612ee8f1950c5cbf77e24eed
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:51:07 2021 +0200
init
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ cat test.txt
a
b
c
e
f
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git merge b
Auto-merging test.txt
Merge made by the 'recursive' strategy.
test.txt | 1 +
1 file changed, 1 insertion(+)
lukas@DESKTOP-F2SE3C1 MINGW64 ~/test
$ git log
commit ed9752a4af2979b5965b87c9052737817aa53533 (HEAD -> main)
Merge: ac038b0 dca1b82
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:53:58 2021 +0200
Merge branch 'b'
commit ac038b0e5d9a817ba381a2450514b0abf07e5ff6
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:41 2021 +0200
-d
commit dca1b8204c809fb0201d6e01ced10163aec4dc41 (b)
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:41 2021 +0200
-d
commit f478ad6965ed8c824c7ac75a3cb35135bc5220d3
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:52:24 2021 +0200
g
commit c80048e572b677b9612ee8f1950c5cbf77e24eed
Author: Lukas Eder <[email protected]>
Date: Tue Sep 14 19:51:07 2021 +0200
init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment