Last active
June 2, 2023 12:26
-
-
Save rick-nu/24e7da38e6dd95ed3099 to your computer and use it in GitHub Desktop.
.gitconfig
This file contains hidden or 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
| [alias] | |
| # View the SHA, description, and history graph of the latest 30 commits | |
| l = log --pretty=oneline -n 30 --graph --abbrev-commit | |
| # View the current working tree status using the short format | |
| s = status -sb | |
| # Show the diff between the latest commit and the current state | |
| d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" | |
| # `git di $number` shows the diff between the state `$number` revisions ago and the current state | |
| di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" | |
| # Clone a repository including all submodules | |
| c = clone --recursive | |
| # Commit all changes | |
| ca = !git add -A && git commit -av | |
| # Switch to a branch, creating it if necessary | |
| go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f" | |
| # Show verbose output about tags, branches or remotes | |
| tags = tag -l | |
| # Create a new tag | |
| newtag = tag -a -s | |
| # Show a list of all local branches | |
| b = branch | |
| # List remotes | |
| remotes = remote -v | |
| # Interactive rebase with the given number of latest commits | |
| reb = "!r() { git rebase -i HEAD~$1; }; r" | |
| # Pull an upstream PR | |
| pr = "!pr() { git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1; git checkout origin/pr/$1; }; pr" | |
| # Pull an upstream merge request (GitLab) | |
| mr = "!mr() { git fetch upstream refs/merge-requests/$1/head:refs/remotes/upstream/merge-requests/$1; git checkout upstream/merge-requests/$1; }; mr" | |
| # Remove all local branches merged into your local branch (delete-if-in master) | |
| delete-if-in = "!f() { git checkout --quiet \"$1\" && git branch --merged | grep --invert-match '\\*' | xargs -n 1 git branch --delete; git checkout --quiet @{-1}; }; f" | |
| # List contributors with number of commits | |
| contributors = shortlog --summary --numbered | |
| # Push commits to the current local branch | |
| pc = push origin HEAD | |
| # Force push current branch with lease | |
| pcf = push --force-with-lease origin HEAD | |
| # Pull the latest changes on the origin | |
| po = !"git pull origin $(git branch --show-current)" | |
| [user] | |
| email = "<your_email_here>" | |
| name = "<your_name_here>" | |
| signingkey = "<your_gpg_key_name_here>" | |
| [commit] | |
| gpgsign = true | |
| [color] | |
| ui = auto | |
| [color "branch"] | |
| current = green | |
| local = yellow | |
| remote = red | |
| [color "diff"] | |
| meta = yellow bold | |
| frag = magenta bold | |
| old = red bold | |
| new = green bold | |
| [color "status"] | |
| added = green | |
| changed = yellow | |
| untracked = red | |
| [pull] | |
| rebase = true | |
| [core] | |
| editor = vim | |
| # excludesfile = /home/YOUR_USER/.gitignore_global | |
| [pager] | |
| branch = false | |
| log = false | |
| tag = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use this, don't forget to replace
<your_email_here>and<your_name_here>