Last active
March 29, 2018 00:00
-
-
Save peterneave/87673b82426fba14e028cfc6b3cdd4fc to your computer and use it in GitHub Desktop.
Git Random
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
#Make it easier working with upstream branches | |
git config --global pull.rebase true | |
git config --global rebase.autoStash true | |
#log difference between branches | |
git log --oneline --graph --all --decorate --abbrev-commit master..release/5.1.0 | |
#https://til.hashrocket.com/posts/18139f4f20-list-different-commits-between-two-branches | |
git log --left-right --graph --cherry-pick --oneline release/5.1.0...master | |
#Get all the tickets in an upcoming release - gitflow style branches | |
git log --cherry-pick --oneline release/5.1.0...master | grep -oP --regexp="\w+\/\w{2,3}-\w+" | sort | uniq | |
#files affected | |
git diff --name-only master..release/5.1.0 | |
git diff --name-status master..release/5.1.0 | |
#http://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore | |
git rm --cached -r . | |
git add . | |
git clean -xdfn | |
#To stash untracked files without staging them - https://stackoverflow.com/questions/835501/how-do-you-stash-an-untracked-file | |
git stash save -u | |
Remove Branches that have been merged on default | |
git branch -r --merged | grep -vE "develop|master" | sed 's/origin\///' | xargs -n 1 git push --delete origin | |
#https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged | |
#Git Prune | |
git reflog expire --expire="1 hour" --all | |
git reflog expire --expire-unreachable="1 hour" --all | |
git prune --expire="1 hour" -v | |
git gc --aggressive --prune="1 hour" | |
#Git Debug | |
GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -v" GIT_CURL_VERBOSE=1 <your_git_command> | |
e.g. GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -v" GIT_CURL_VERBOSE=1 git push <repo_slug> | |
# Get Branch Authors | |
# Credit http://stackoverflow.com/a/2514279 / https://gist.github.com/l15n/3103708 | |
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment