Skip to content

Instantly share code, notes, and snippets.

@AlwxSin
Last active July 10, 2018 13:04
Show Gist options
  • Save AlwxSin/c50bfcf120df2df36258baad82c6619e to your computer and use it in GitHub Desktop.
Save AlwxSin/c50bfcf120df2df36258baad82c6619e to your computer and use it in GitHub Desktop.
useful git commands
# show only file names
git diff --name-only SHA HEAD~1 > diff.txt
# delete old branches
git branch -a > branches.txt # dump all branches to file
&& sed -i '' 's/\/remote\/origin\///g' branches.txt # replace unneeded '/remote/origin/' prefix
&& nano branches.txt # manually delete branches that need to be keeped
&& cat branches.txt | xargs -I {} git push origin :{} # delete unneeded branches
# show added/deleted lines count
git log --author="Alwx" --pretty=tformat: --shortstat | cut -d' ' -f5,7 | awk '{for (i=1;i<=NF;i++) sum[i]+=$i;}; END{for (i in sum) print sum[i];}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment