sh/shell/alias/git.sh
2024-11-17 03:09:36 +01:00

468 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 \
"${@}"
}
# redo the last commit with a different message
gcam() {
git \
commit \
--amend \
--message \
"${@}"
}
# make a root commit
gcem() {
git \
commit \
--allow-empty \
--allow-empty-message \
--message \
"${@}"
}
# clean untracked files
gcf() {
git \
clean \
-d \
--force \
"${@}"
}
# commit the index
gcm() {
git \
commit \
--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 history
gl() {
local format="\
%C(auto)%h%d
S %C(red)%GS
A %C(green)%ai
%C(green)%an %ae
C %C(blue)%ci
%C(blue)%cn %ce
%B"
git \
log \
--abbrev=8 \
--abbrev-commit \
--format="${format}" \
--graph \
"${@}"
}
# log all history
gla() {
gl \
--all \
"${@}"
}
# log all history with patches
glap() {
gl \
--all \
--patch \
"${@}"
}
# log history with patches
glp() {
gl \
--patch \
"${@}"
}
# abort the current merge commit
gma() {
git \
merge \
--abort \
"${@}"
}
# do a merge commit
gmc() {
git \
merge \
--no-ff \
--message \
"${@}"
}
# fast-forward to remote branch
gmf() {
git \
merge \
--ff-only \
"${@}"
}
# squash a branch and index its modifications
gms() {
git \
merge \
--squash \
"${@}"
}
# merge via external tool
gmt() {
git \
mergetool \
"${@}"
}
# push to the remote repository
gp() {
git \
push \
--tags \
--verbose \
"${@}"
}
# delete from the remote repository
gpd() {
git \
push \
--delete \
"${@}"
}
# force the push to the remote repository
gpf() {
gp \
--force \
"${@}"
}
# rebase current branch onto another
grb() {
git \
rebase \
"${@}"
}
# abort current rebase
grba() {
git \
rebase \
--abort \
"${@}"
}
# continue current rebase
grbc() {
git \
rebase \
--continue \
"${@}"
}
# force rebase without fast-forward
grbf() {
git \
rebase \
--force-rebase \
"${@}"
}
# rebase interactively
grbi() {
git \
rebase \
--interactive \
"${@}"
}
# remove and add removal to index
grm() {
git \
rm \
"${@}"
}
# add a new remote repository
grma() {
git \
remote \
add \
"${@}"
}
# list remote repositories
grml() {
git \
remote \
--verbose \
"${@}"
}
# set the location of the remote repository
grms() {
git \
remote \
set-url \
"${@}"
}
# remove file(s) from index or move current branch pointer
grs() {
git \
reset \
"${@}"
}
# wipe modifications or reset current branch to another commit
grsh() {
git \
reset \
--hard \
"${@}"
}
# current state of repository
gs() {
git \
status \
--untracked-files="all" \
"${@}"
}
# show a commit
gsc() {
git \
show \
"${@}"
}
# tag a commit
gt() {
git \
tag \
"${@}"
}
# delete a tag
gtd() {
git \
tag \
--delete \
"${@}"
}