sh/shell/alias/git.sh
2024-11-16 19:08:27 +01:00

465 lines
4.8 KiB
Bash

# add to index
ga() {
git \
add \
"${@}"
}
# add all to index
gaa() {
git \
add \
--all \
"${@}"
}
# add parts of all to index
gaap() {
git \
add \
--all \
--patch \
"${@}"
}
# add parts to index
gap() {
git \
add \
--patch \
"${@}"
}
# create a branch
gb() {
git \
branch \
"${@}"
}
# delete a branch
gbd() {
git \
branch \
--delete \
"${@}"
}
# force a branch deletion
gbdf() {
git \
branch \
--delete \
--force \
"${@}"
}
# list branches
gbl() {
git \
branch \
--all \
--list \
--verbose \
--verbose \
"${@}"
}
# set the link to a remote branch from a local branch
gbs() {
git \
branch \
--set-upstream-to \
"${@}"
}
# clean untracked files
gcf() {
git \
clean \
-d \
--force \
"${@}"
}
# commit the index
alias gcm="\
git \
commit \
--message \
"
# redo the last commit with a different message
alias gcma="\
git \
commit \
--amend \
--message \
"
# make a root commit
alias gcme="\
git \
commit \
--allow-empty \
--allow-empty-message \
--message \"\" \
"
# commit the index and sign
alias gcms="\
git \
commit \
--gpg-sign \
--message \
"
# switch to a branch or checkout file(s) from a commit
gco() {
git \
checkout \
"${@}"
}
# checkout an orphan branch
gcoo() {
git \
checkout \
--orphan \
"${@}"
}
# pick a commit
gcp() {
git \
cherry-pick \
"${@}"
}
# abort the commit pick
gcpa() {
git \
cherry-pick \
--abort \
"${@}"
}
# continue the commit pick
gcpc() {
git \
cherry-pick \
--continue \
"${@}"
}
# configure the user email
gcue() {
git \
config \
"user.email" \
"${@}"
}
# configure the user name
gcun() {
git \
config \
"user.name" \
"${@}"
}
# differences from last or between commits
gd() {
git \
diff \
"${@}"
}
# display what is indexed in cache
gdc() {
git \
diff \
--cached \
"${@}"
}
# indexed character-level differences
gdcw() {
git \
diff \
--cached \
--word-diff-regex "." \
"${@}"
}
# differences via external tool
gdt() {
git \
difftool \
--dir-diff \
"${@}"
}
# character-level differences
gdw() {
git \
diff \
--word-diff-regex "." \
"${@}"
}
# fetch from the remote repository
gf() {
git \
fetch \
--tags \
--verbose \
"${@}"
}
# fetch from remote repository and prune local orphan branches
gfp() {
gf \
--prune \
"${@}"
}
# garbage collect all orphan commits
ggc() {
git \
reflog \
expire \
--all \
--expire "all" &&
git \
gc \
--aggressive \
--prune="now"
}
# initialize a new repository
gi() {
git \
init \
"${@}"
}
# initialize a new bare repository
gib() {
git \
init \
--bare \
"${@}"
}
# log commits history
alias gl="\
git \
log \
--all \
--graph \
--format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \
"
# log medium information
alias glm="\
git \
log \
--all \
--decorate \
--graph \
--pretty=medium \
"
# log commits history with patches
alias glp="\
git \
log \
--all \
--graph \
--format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \
--patch \
"
# abort the current merge commit
alias gma="\
git \
merge \
--abort \
"
# do a merge commit
alias gmc="\
git \
merge \
--no-ff \
--message \
"
# do a signed merge commit
alias gmcs="\
git \
merge \
--no-ff \
--gpg-sign \
-m \
"
# fast-forward to remote branch
alias gmf="\
git \
merge \
--ff-only \
"
# squash a branch and index its modifications
alias gms="\
git \
merge \
--squash \
"
# merge via external tool
alias gmt="\
git \
mergetool \
"
# push to the remote repository
alias gp="\
git \
push \
--verbose \
--tags \
"
# delete from the remote repository
alias gpd="\
git \
push \
--verbose \
--delete \
"
# force the push to the remote repository
alias gpf="\
git \
push \
--verbose \
--tags \
--force \
"
# rebase current branch onto another
alias grb="\
git \
rebase \
"
# abort current rebase
alias grba="\
git \
rebase \
--abort \
"
# continue current rebase
alias grbc="\
git \
rebase \
--continue \
"
# force rebase without fast-forward
alias grbf="\
git \
rebase \
--force-rebase \
"
# rebase interactively
alias grbi="\
git \
rebase \
--interactive \
"
# remove and add removal to index
alias grm="\
git \
rm \
"
# add a new remote repository
alias grma="\
git \
remote \
add \
"
# list remote repositories
alias grml="\
git \
remote \
--verbose \
"
# show a connection to a repository
alias grms="\
git \
remote \
show \
"
# set the location of the remote repository
alias grmsu="\
git \
remote \
set-url \
"
# remove file(s) from index or move current branch pointer
alias grs="\
git \
reset \
"
# wipe modifications or reset current branch to another commit
alias grsh="\
git \
reset \
--hard \
"
# current state of repository
alias gs="\
git \
status \
--untracked-files=all \
"
# show a commit
alias gsc="\
git \
show \
"
# tag a commit
alias gt="\
git \
tag \
"
# delete a tag
alias gtd="\
git \
tag \
--delete \
"
# tag a commit and sign
alias gts="\
git \
tag \
--sign \
"