sh/shell/alias/git.sh

467 lines
4.8 KiB
Bash
Raw Normal View History

2023-05-09 20:02:34 +00:00
# add to index
2024-11-16 15:59:23 +00:00
ga() {
git \
add \
"${@}"
}
2023-05-09 20:02:34 +00:00
# add all to index
2024-11-16 15:59:23 +00:00
gaa() {
git \
add \
--all \
"${@}"
}
2023-05-09 20:02:34 +00:00
2024-11-16 16:01:12 +00:00
# add parts of all to index
gaap() {
git \
add \
--all \
--patch \
"${@}"
}
2023-05-14 20:48:39 +00:00
# add parts to index
2024-11-16 16:01:12 +00:00
gap() {
git \
add \
--patch \
"${@}"
}
2023-05-14 20:48:39 +00:00
2023-05-09 20:02:34 +00:00
# create a branch
2024-11-16 17:43:09 +00:00
gb() {
git \
branch \
"${@}"
}
2023-05-09 20:02:34 +00:00
# delete a branch
2024-11-16 17:43:09 +00:00
gbd() {
git \
branch \
--delete \
"${@}"
}
2023-05-09 20:02:34 +00:00
# force a branch deletion
2024-11-16 17:43:09 +00:00
gbdf() {
git \
branch \
--delete \
--force \
"${@}"
}
2023-05-09 20:02:34 +00:00
# list branches
2024-11-16 17:43:09 +00:00
gbl() {
git \
branch \
--all \
--list \
--verbose \
--verbose \
"${@}"
}
2023-05-09 20:02:34 +00:00
# set the link to a remote branch from a local branch
2024-11-16 17:43:09 +00:00
gbs() {
git \
branch \
--set-upstream-to \
"${@}"
}
2023-05-09 20:02:34 +00:00
# clean untracked files
2024-11-16 17:48:01 +00:00
gcf() {
git \
clean \
-d \
--force \
"${@}"
}
2023-05-09 20:02:34 +00:00
# commit the index
2023-05-18 10:34:05 +00:00
alias gcm="\
2023-05-14 20:56:05 +00:00
git \
commit \
2023-05-15 07:02:33 +00:00
--message \
2023-05-14 20:56:05 +00:00
"
2023-05-09 20:02:34 +00:00
# redo the last commit with a different message
2023-05-18 10:34:05 +00:00
alias gcma="\
2023-05-14 20:56:05 +00:00
git \
commit \
--amend \
2023-05-15 07:02:33 +00:00
--message \
2023-05-14 20:56:05 +00:00
"
2023-05-09 20:02:34 +00:00
# make a root commit
2023-05-18 10:34:05 +00:00
alias gcme="\
2023-05-14 20:56:05 +00:00
git \
commit \
--allow-empty \
--allow-empty-message \
2023-05-15 07:02:33 +00:00
--message \"\" \
2023-05-14 20:56:05 +00:00
"
2023-05-09 20:02:34 +00:00
# commit the index and sign
2023-05-18 10:34:05 +00:00
alias gcms="\
2023-05-14 20:56:05 +00:00
git \
commit \
--gpg-sign \
2023-05-15 07:02:33 +00:00
--message \
2023-05-14 20:56:05 +00:00
"
2023-05-09 20:02:34 +00:00
# switch to a branch or checkout file(s) from a commit
2024-11-16 17:51:33 +00:00
gco() {
git \
checkout \
"${@}"
}
2023-05-09 20:02:34 +00:00
# checkout an orphan branch
2024-11-16 17:51:33 +00:00
gcoo() {
git \
checkout \
--orphan \
"${@}"
}
2023-05-09 20:02:34 +00:00
# pick a commit
2024-11-16 17:51:33 +00:00
gcp() {
git \
cherry-pick \
"${@}"
}
2023-05-09 20:02:34 +00:00
# abort the commit pick
2024-11-16 17:51:33 +00:00
gcpa() {
git \
cherry-pick \
--abort \
"${@}"
}
2023-05-09 20:02:34 +00:00
# continue the commit pick
2024-11-16 17:51:33 +00:00
gcpc() {
git \
cherry-pick \
--continue \
"${@}"
}
2023-05-09 20:02:34 +00:00
# configure the user email
2024-11-16 17:54:56 +00:00
gcue() {
git \
config \
"user.email" \
"${@}"
}
# configure the user name
gcun() {
git \
config \
"user.name" \
"${@}"
}
2023-05-09 20:02:34 +00:00
# differences from last or between commits
2024-11-16 18:01:27 +00:00
gd() {
git \
diff \
"${@}"
}
2023-05-09 20:02:34 +00:00
# display what is indexed in cache
2024-11-16 18:01:27 +00:00
gdc() {
git \
diff \
--cached \
"${@}"
}
2023-05-09 20:02:34 +00:00
# indexed character-level differences
2024-11-16 18:01:27 +00:00
gdcw() {
git \
diff \
--cached \
--word-diff-regex "." \
"${@}"
}
2023-05-09 20:02:34 +00:00
# differences via external tool
2024-11-16 18:01:27 +00:00
gdt() {
git \
difftool \
--dir-diff \
"${@}"
}
2023-05-09 20:02:34 +00:00
# character-level differences
2024-11-16 18:01:27 +00:00
gdw() {
git \
diff \
--word-diff-regex "." \
"${@}"
}
2023-05-09 20:02:34 +00:00
# fetch from the remote repository
2024-11-16 18:02:56 +00:00
gf() {
git \
fetch \
--tags \
--verbose \
"${@}"
}
2023-05-09 20:02:34 +00:00
# fetch from remote repository and prune local orphan branches
2024-11-16 18:02:56 +00:00
gfp() {
gf \
--prune \
"${@}"
}
2023-05-09 20:02:34 +00:00
# garbage collect all orphan commits
2024-11-16 18:07:11 +00:00
ggc() {
git \
reflog \
expire \
--all \
--expire "all" &&
git \
gc \
--aggressive \
--prune="now"
}
2023-05-09 20:02:34 +00:00
# initialize a new repository
2024-11-16 18:08:27 +00:00
gi() {
git \
init \
"${@}"
}
2023-05-09 20:02:34 +00:00
# initialize a new bare repository
2024-11-16 18:08:27 +00:00
gib() {
git \
init \
--bare \
"${@}"
}
2023-05-09 20:02:34 +00:00
2024-11-16 19:27:36 +00:00
# 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 \
"${@}"
}
2024-11-16 18:17:36 +00:00
# log all history
gla() {
2024-11-16 19:27:36 +00:00
gl \
2024-11-16 18:17:36 +00:00
--all \
"${@}"
}
2024-11-16 19:27:36 +00:00
# log all history with patches
glap() {
gl \
--all \
--patch \
2024-11-16 18:17:36 +00:00
"${@}"
}
2023-05-09 20:02:34 +00:00
2024-11-16 19:27:36 +00:00
# log history with patches
glp() {
gl \
--patch \
"${@}"
}
2023-05-09 20:02:34 +00:00
2023-05-14 20:29:47 +00:00
# abort the current merge commit
2024-11-17 01:26:32 +00:00
gma() {
git \
merge \
--abort \
"${@}"
}
2023-05-09 20:02:34 +00:00
# do a merge commit
2024-11-17 01:26:32 +00:00
gmc() {
git \
merge \
--no-ff \
--message \
"${@}"
}
2023-05-09 20:02:34 +00:00
2023-05-14 20:29:47 +00:00
# fast-forward to remote branch
2024-11-17 01:26:32 +00:00
gmf() {
git \
merge \
--ff-only \
"${@}"
}
2023-05-09 20:02:34 +00:00
# squash a branch and index its modifications
2024-11-17 01:26:32 +00:00
gms() {
git \
merge \
--squash \
"${@}"
}
2023-05-09 20:02:34 +00:00
# merge via external tool
2024-11-17 01:26:32 +00:00
gmt() {
git \
mergetool \
"${@}"
}
2023-05-09 20:02:34 +00:00
# push to the remote repository
2023-05-14 16:53:19 +00:00
alias gp="\
git \
push \
--verbose \
--tags \
"
2023-05-09 20:02:34 +00:00
# delete from the remote repository
2023-05-14 16:53:19 +00:00
alias gpd="\
git \
push \
--verbose \
--delete \
"
2023-05-09 20:02:34 +00:00
# force the push to the remote repository
2023-05-14 16:53:19 +00:00
alias gpf="\
git \
push \
--verbose \
--tags \
--force \
"
2023-05-09 20:02:34 +00:00
# rebase current branch onto another
2023-05-14 16:50:19 +00:00
alias grb="\
git \
rebase \
"
2023-05-09 20:02:34 +00:00
# abort current rebase
2023-05-14 16:50:19 +00:00
alias grba="\
git \
rebase \
--abort \
"
2023-05-09 20:02:34 +00:00
# continue current rebase
2023-05-14 16:50:19 +00:00
alias grbc="\
git \
rebase \
--continue \
"
2023-05-09 20:02:34 +00:00
# force rebase without fast-forward
2023-05-14 16:50:19 +00:00
alias grbf="\
git \
rebase \
--force-rebase \
"
2023-05-09 20:02:34 +00:00
# rebase interactively
2023-05-14 16:50:19 +00:00
alias grbi="\
git \
rebase \
--interactive \
"
2023-05-09 20:02:34 +00:00
2023-05-18 11:51:20 +00:00
# remove and add removal to index
2023-05-14 16:17:18 +00:00
alias grm="\
git \
rm \
"
2023-05-09 20:02:34 +00:00
# add a new remote repository
2023-05-14 16:17:18 +00:00
alias grma="\
git \
remote \
add \
"
2023-05-09 20:02:34 +00:00
# list remote repositories
2023-05-14 16:17:18 +00:00
alias grml="\
git \
remote \
--verbose \
"
2023-05-09 20:02:34 +00:00
# show a connection to a repository
2023-05-14 16:17:18 +00:00
alias grms="\
git \
remote \
show \
"
2023-05-09 20:02:34 +00:00
# set the location of the remote repository
2023-05-14 16:17:18 +00:00
alias grmsu="\
git \
remote \
set-url \
"
2023-05-09 20:02:34 +00:00
# remove file(s) from index or move current branch pointer
2023-05-14 16:11:10 +00:00
alias grs="\
git \
reset \
"
2023-05-09 20:02:34 +00:00
# wipe modifications or reset current branch to another commit
2023-05-14 16:11:10 +00:00
alias grsh="\
git \
reset \
--hard \
"
2023-05-09 20:02:34 +00:00
# current state of repository
2023-05-14 20:58:58 +00:00
alias gs="\
git \
status \
--untracked-files=all \
"
2023-05-09 20:02:34 +00:00
# show a commit
2023-05-14 20:58:58 +00:00
alias gsc="\
git \
show \
"
2023-05-09 20:02:34 +00:00
# tag a commit
2023-05-14 16:07:01 +00:00
alias gt="\
git \
tag \
"
2023-05-09 20:02:34 +00:00
# delete a tag
2023-05-14 16:07:01 +00:00
alias gtd="\
git \
tag \
--delete \
"