save this file as ~/.gitcongig
Optionally you can isntall .gitignore_global: https://gist.github.com/oleg-koval/4318ac5e92875fa2714ddeb51764853f
| [user] | |
| name = Ragnar Lodbrok | |
| email = ragnar.lodbrok@valhala.se | |
| [credential] | |
| helper = osxkeychain | |
| [core] | |
| editor = atom --wait | |
| excludesfile = /Users/ragnarlodbrok/.gitignore_global | |
| [url "https://github.com/"] | |
| insteadOf = gh: | |
| [url "https://gist.github.com/"] | |
| insteadOf = gist: | |
| [url "https://bitbucket.org/"] | |
| insteadOf = bb: | |
| [diff] | |
| mnemonicprefix = true | |
| [alias] | |
| # Add and remove all changes, note how this alias is calling another alias | |
| addremove = !git r && git add . --all | |
| # Show all of my configured aliases | |
| aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort | |
| # For when you made that commit a bit too early, amend | |
| amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend | |
| # Show all branches | |
| br = branch -av | |
| # Show the current branch name (usefull for shell prompts) | |
| brname = !git branch | grep "^*" | awk '{ print $2 }' | |
| # Delete a branch | |
| brdel = branch -D | |
| # Which files are receiving the most "love" | |
| churn = !git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count,file"} {print $1 "," $2}' | |
| # View the log and diff for a commit (previous if no SHA1 provided) | |
| details = log -n1 -p --format=fuller | |
| # Save a repo as a tarball | |
| export = archive -o latest.tar.gz -9 --prefix=latest/ | |
| # Unstage changes from the index | |
| unstage = reset HEAD -- | |
| # View a pretty git log with branch tree | |
| g = !git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
| # Return a list of commit SHA1s | |
| l = "!f() { git log $* | grep '^commit ' | cut -f 2 -d ' '; }; f" | |
| # Remove deleted files | |
| r = !git ls-files -z --deleted | xargs -0 git rm | |
| # Return the repository's root directory (usefull for shell prompts) | |
| root = rev-parse --show-toplevel | |
| # Update all submodules | |
| subup = submodule update --init | |
| # List all tags | |
| tags = tag -l | |
| # Start a new local repository and perform initial commit | |
| this = !git init && git add . && git commmit -m \"Initial commit.\" | |
| # Thin out older metadata within the repository, reduceses filesystem footprint | |
| trim = !git reflog expire --expire=now --all && git gc --prune=now | |
| # Check what you are adding step-by-step | |
| addp = add -p | |
| # Fancy git logs | |
| lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative | |
| lg2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit | |
| lg = !"git lg1" | |
| # Last tag in current branch | |
| lastag = describe --exact-match --abbrev=0 | |
| # Push branch to remote | |
| superpush = !git push --set-upstream origin $(echo $(git brname)) | |
| # Last tag in current branch | |
| lastag1 = describe --exact-match --abbrev=0 | |
| lastag2 = describe --abbrev=0 --tags | |
| # Push branch to remote | |
| superpush = !git push --set-upstream origin $(echo $(git brname)) | |
| # reset master to remote | |
| resetmaster = !git fetch origin && echo "Reseting master branch to remote" && git reset --hard origin/master && git fetch --tags | |
| # reset current branch to remote | |
| resetbr = !git fetch origin && echo "Reseting current branch to remote" && git reset --hard origin/$(echo $(git brname)) && git fetch --tags | |
| #remove remote tag | |
| rmlastagr = !git push --delete origin $(echo $(git lastag2)) | |
| #remove local tag | |
| rmlastag = !git push --delete $(git lastag2) | |
| # list remote tags | |
| lsremotetags = ls-remote --tags origin | |
| # cleanup local tags | |
| cleanuptags = !git tag -l | xargs git tag -d && git fetch --tags | |
| # git ls-remote --tags origin | git show-ref --tags --exclude-existing | |
| # Pull && Fetch remote tags | |
| pul = !git pull && echo "Fetching remote tags" && "git cleanuptags" | |
save this file as ~/.gitcongig
Optionally you can isntall .gitignore_global: https://gist.github.com/oleg-koval/4318ac5e92875fa2714ddeb51764853f