Skip to content

Instantly share code, notes, and snippets.

@eegeeZA
Created October 10, 2018 19:36
Show Gist options
  • Save eegeeZA/1043bb894f2393cb45b759af35918cb0 to your computer and use it in GitHub Desktop.
Save eegeeZA/1043bb894f2393cb45b759af35918cb0 to your computer and use it in GitHub Desktop.
Example of how a commit might go "missing" when renamed on Git
git checkout -b branch1
touch test.txt
git add .
git commit -m "Commit 1"
for i in `seq 1 10`; do echo $i >> test.txt; done
git add .
git commit -m "Commit 2"
git checkout -b branch2
mv test.txt renamed.txt
git add .
git commit -m "Commit 3"
git checkout branch1
rm test.txt
touch test.txt
for i in `seq 1 4`; do echo $i >> test.txt; done
for i in `seq 8 10`; do echo $i >> test.txt; done
git add .
git commit -m "Commit 4 (missing)"
git checkout branch1
git merge branch2 --no-edit
for i in `seq 5 7`; do echo $i >> renamed.txt; done
git add .
git commit -m "Commit 5"
#missing commit
git log --follow -- renamed.txt
# vs all commits
git log --follow --topo-order -- renamed.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment