May 03, 2018 • ☕️ 2 min read
I had a very old Git branch (NewBranch) where I did some new development. In the meantime, the branch I originally branched from (OriginalBranch) was so different that I only wanted to copy out the changed files into a zip file. I found some funky Git one-liner commands that work on Linux/Mac, but I’m on good old Windows. I managed to do it as follows:
zip.exe
executable somewhere into your path. I always have a c:\bin
folder that is added to my path and I copy all tools into this directory. For zip.exe
I use Info-ZIP.git checkout NewBranch
. Make sure you get the latest files using git pull
. To see your list of branches and the currently checked out branch use the command git branch -a
.git merge-base OriginalBranch NewBranch
. This is a value that looks like be61fd84b7abe0b4735a21367ba70db68e5e4ef9
. If you want an overview of last commits execute the following command: git log --pretty=format:"%H - %an, %ar: %s"
. If you don’t like the long commit hashes you can also work with the abbreviated commit hashes. In this case use %h
instead.git diff --name-only be61fd84b7abe0b4735a21367ba70db68e5e4ef9 > diff-filelist.txt
. Where you use the commit hash of the commit from where you want to get the files from.more diff-filelist.txt | zip -@ files.zip
.Discuss on Twitter • Edit on GitHub
Personal blog by Serge van den Oever - als je maar lol hebt...
Twitter: @svdoever
LinkedIn: Serge van den Oever - articles on LinkedIn
Technology Consultant @ Macaw
Competence Team Lead Custom Application Development @ Macaw
2022 Technology Sitecore Most Valuable Professional
2021 Technology Sitecore Most Valuable Professional