Reputation: 8200
On my staging branch, I committed a folder migrations_lar
with 1 migration file in it. I found the commit where I added it on November 29th. When I look at the staging branch now, the entire migrations_lar
folder is gone. I need to find out when it disappeared. I also want to know if anything else disappeared.
Here is what I have learned:
I ran git log -- database/migrations_lar
The commit where I added the folder has the message "Implement Partner Webhook". None of those other commits delete the folder.
When I get on GitHub and check the status of the staging branch after various commits, I see that folder appears and disappears regularly:
The highlighted rows DO NOT have my commit, and do not have the migrations_lar folder.
The bottom commit has the migrations_lar folder when it was initially created long ago, without my file in it.
I am just completely stumped as to how or when this got lost, and what got lost with it. Any help?
Months ago I added the migrations_lar folder with Laravel's default migrations in it. At some point someone deleted the files therefore the folder.
On Nov 29th I added the folder and the new migration.
At some point after that (I assume) someone created a bad merge with the original deletion. I don't know how this happened. Any clue on how I could find the commit that shows when that file was deleted?!
Upvotes: 1
Views: 346
Reputation: 1324357
Another approach, beside bisect, is to git log
, focusing on deletion.
See "Find when a file was deleted in Git"
git log --diff-filter=D --summary | \
sed -n '/^commit/h;/\/some_dir\//{G;s/\ncommit \(.*\)/ \1/gp}'
On Mac:
git log --diff-filter=D --summary | \
sed -n -e '/^commit/h' -e '\:/:{' -e G -e 's/\ncommit \(.*\)/ \1/gp' -e }
That would list all commits where files within a folder have disappeared.
Upvotes: 1
Reputation: 8200
Thank you @Ryan. I tried git bisect to find the commit that caused the issue. And I think it helped. I think it identified the commit, but I ignored it.
Then I called git checkout HEAD^; ls database/migrations_lar
until I found the commit that had the folder. I found the commit string of the the faulting commit and ran git show https://github.com/completesolar/HelioTrack/commit/226d0b8f940a7bec524360a0f631d87f46dfaab8
.
Sure enough I saw
...017_11_28_100558_create_organizations_table.php | 54 ---
Then i realized this commit was when I merged a Pull Request. I reviewed that Pull request and sure enough I had missed that full on code review. From that pull request I revied the 30 commits on the Pull Request and found the offending failed merge.
Upvotes: 1