git common operation command alias abbreviation

Original link: https://chegva.com/5370.html

You need to use git commands frequently at work, and using some shorthand commands can still improve the efficiency.

Just put it under ~ /.zshrc on mac, execute source ~/.zshrc after adding, create ~/.bash_aliases in linux, add [[ -f ~/.bash_aliases ]] && source ~/. bash_aliases content

First add the following configuration to ~/.gitconfig :

 [alias] st = status # Checkout a branch co = checkout # Checkout a new not yet existing branch ci = commit # Commit you changes ft = fetch -p # Fetch from a repository pu = push # Push you changes to repository ba = branch -a # List both remote-tracking branches and local branches bd = branch -d # Delete a branch only if it has been merged dc = diff --cached # Display the staged changes lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an> %Creset' --abbrev-commit # Display Submit log rk = shortlog -sn --no-merges # Display Contributor ranking [user] name = anzhihe email = [email protected]

Add the following configuration to ~/.zshrc :

 alias git='LANG=en_GB git' # Mac git Chinese prompt changed to English  alias gin='git init' # Initialize repository  alias gst='git st' # View status  alias gdf='git diff' # View the modified content  alias gad='git add *' # add to the staging area  gci(){ git ci -am "$*"; } # Commit to local repository  alias glg='git lg' # View commit history  alias grg='git reflog' # View operation history  alias gco='git checkout -- ' # Abandon the modification and add it to the staging area  alias grh='git reset HEAD^' # go back to the previous version  #alias gra ='git remote add' # Add remote address  alias gpl='git pull' # update repository  alias gba='git branch -a' # View branch  alias gbb='git branch -b' # create and switch to branch  alias gps='git push' # Submit remote warehouse  alias gpur='git pull upstream master --rebase' # Update the associated upstream project  # Batch update multiple repositories  alias gpa="find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull"

refer to:

This article is reprinted from: https://chegva.com/5370.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment