Last active
October 6, 2020 02:15
-
-
Save tzaffi/810a3ee9398c94b1129ac54b75d45d80 to your computer and use it in GitHub Desktop.
#CrazyOneliner show the most recent git commit of all deleted files in your current branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git status|grep deleted|cut -d " " -f 5 > deleted.deleteme&&git stash&&git checkout master&&cat d.d.d.d|xargs -t -I@ git --no-pager log -1 --format=%cd @&&git checkout - >/dev/null&&git stash apply >/dev/null&&rm d.d.d.d | |
# EXPLANATION | |
# 1. list all the deleted files in current branch (first 3 piped commands) | |
# 2. save them in a file called "deleted.deleteme" (output of 3rd command) | |
# 3. save their most recent commit dates back into "deleted.deleteme" by changing into the master branch and coming back (commands 4 thru 9) | |
# 4. cleanup by removing "deleted.deleteme" | |
WARNING: I hope you don't have a file called `d.d.d.d` as it will be deleted! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment