mirror of
https://github.com/ChrisTitusTech/mybash.git
synced 2026-04-13 07:59:32 +00:00
Add git aliases for easier workflow
This commit introduces a series of git aliases to simplify common tasks. These include shortcuts for status, clone, pull, push, diff, commit, checkout, branch, cherry-pick, log, reset, and submodule update. Additionally, two functions have been added to easily retrieve the current branch and repository. The aliases are defined in the shell configuration file (.bashrc, .zshrc, etc.) and should be available in any new terminal session. The exact location and method of defining these aliases may vary depending on the shell being used.
This commit is contained in:
61
.bashrc
61
.bashrc
@@ -591,6 +591,67 @@ lazyg() {
|
||||
git commit -m "$1"
|
||||
git push
|
||||
}
|
||||
|
||||
# Aliases git
|
||||
alias g='git'
|
||||
compdef g=git
|
||||
alias gst='git status'
|
||||
compdef _git gst=git-status
|
||||
alias gcl='git clone --recurse-submodules'
|
||||
compdef _git gcl=git-clone
|
||||
alias gl='git pull'
|
||||
compdef _git gl=git-pull
|
||||
alias gup='git fetch && git rebase'
|
||||
compdef _git gup=git-fetch
|
||||
alias gp='git push'
|
||||
compdef _git gp=git-push
|
||||
gdv() { git diff -w "$@" | view - }
|
||||
compdef _git gdv=git-diff
|
||||
alias gc='git commit -v'
|
||||
compdef _git gc=git-commit
|
||||
alias gca='git commit -v -a'
|
||||
compdef _git gca=git-commit
|
||||
alias gco='git checkout'
|
||||
compdef _git gco=git-checkout
|
||||
alias gcm='git checkout master'
|
||||
alias gb='git branch'
|
||||
compdef _git gb=git-branch
|
||||
alias gba='git branch -a'
|
||||
compdef _git gba=git-branch
|
||||
alias gcount='git shortlog -sn'
|
||||
compdef gcount=git
|
||||
alias gcp='git cherry-pick'
|
||||
compdef _git gcp=git-cherry-pick
|
||||
alias glg='git log --stat --max-count=5'
|
||||
compdef _git glg=git-log
|
||||
alias glgg='git log --graph --max-count=5'
|
||||
compdef _git glgg=git-log
|
||||
alias gss='git status -s'
|
||||
compdef _git gss=git-status
|
||||
alias ga='git add'
|
||||
compdef _git ga=git-add
|
||||
alias gm='git merge'
|
||||
compdef _git gm=git-merge
|
||||
alias grh='git reset HEAD'
|
||||
alias grhh='git reset HEAD --hard'
|
||||
compdef _git grhh=git-reset-hard
|
||||
alias gsbm='git submodule update --init --remote --force --recursive'
|
||||
compdef _git gsbm='git-submodule-update'
|
||||
|
||||
#
|
||||
# Will return the current branch name
|
||||
# Usage example: git pull origin $(current_branch)
|
||||
#
|
||||
function current_branch() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
function current_repository() {
|
||||
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo $(git remote -v | cut -d':' -f 2)
|
||||
}
|
||||
_z_cd() {
|
||||
cd "$@" || return "$?"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user