sh/shell/alias/git.sh

444 lines
4.6 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
2023-05-14 20:48:39 +00:00
# add parts to index
alias gap="\
git \
add \
--patch \
"
2023-05-09 20:02:34 +00:00
# create a branch
2023-05-14 15:59:03 +00:00
alias gb="\
git \
branch \
"
2023-05-09 20:02:34 +00:00
# delete a branch
2023-05-14 15:59:03 +00:00
alias gbd="\
git \
branch \
--delete \
"
2023-05-09 20:02:34 +00:00
# force a branch deletion
2023-05-14 15:59:03 +00:00
alias gbdf="\
git \
branch \
--delete \
--force \
"
2023-05-09 20:02:34 +00:00
# list branches
2023-05-14 15:59:03 +00:00
alias 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
2023-05-14 15:59:03 +00:00
alias gbsu="\
git \
branch \
--set-upstream-to \
"
2023-05-09 20:02:34 +00:00
2023-05-18 10:34:05 +00:00
# clone a remote repository
alias gc="\
git \
clone \
"
2023-05-09 20:02:34 +00:00
# clean untracked files
2023-05-14 16:04:13 +00:00
alias 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
2023-05-14 17:49:34 +00:00
alias gco="\
git \
checkout \
"
2023-05-09 20:02:34 +00:00
# checkout an orphan branch
2023-05-14 17:49:34 +00:00
alias gcoo="\
git \
checkout \
--orphan \
"
2023-05-09 20:02:34 +00:00
# pick a commit
2023-05-14 16:57:15 +00:00
alias gcp="\
git \
cherry-pick \
"
2023-05-09 20:02:34 +00:00
# abort the commit pick
2023-05-14 16:57:15 +00:00
alias gcpa="\
git \
cherry-pick \
--abort \
"
2023-05-09 20:02:34 +00:00
# continue the commit pick
2023-05-14 16:57:15 +00:00
alias gcpc="\
git \
cherry-pick \
--continue \
"
2023-05-09 20:02:34 +00:00
# configure the user name
2023-05-14 20:16:55 +00:00
alias gcun="\
git \
config \
user.name \
"
2023-05-09 20:02:34 +00:00
# configure the user email
2023-05-14 20:16:55 +00:00
alias gcue="\
git \
config \
user.email \
"
2023-05-09 20:02:34 +00:00
# differences from last or between commits
2023-05-14 20:15:44 +00:00
alias gd="\
git \
diff \
"
2023-05-09 20:02:34 +00:00
# display what is indexed in cache
2023-05-14 20:15:44 +00:00
alias gdc="\
git \
diff \
--cached \
"
2023-05-09 20:02:34 +00:00
# indexed character-level differences
2023-05-14 20:15:44 +00:00
alias gdcw="\
git \
diff \
--cached \
--word-diff-regex=. \
"
2023-05-09 20:02:34 +00:00
# differences via external tool
2023-05-14 20:15:44 +00:00
alias gdt="\
git \
difftool \
--dir-diff \
"
2023-05-09 20:02:34 +00:00
# character-level differences
2023-05-14 20:15:44 +00:00
alias gdw="\
git \
diff \
--word-diff-regex=. \
"
2023-05-09 20:02:34 +00:00
# fetch from the remote repository
2023-05-14 16:55:39 +00:00
alias gf="\
git \
fetch \
--verbose \
--tags \
"
2023-05-09 20:02:34 +00:00
# fetch from remote repository and prune local orphan branches
2023-05-14 16:55:39 +00:00
alias gfp="\
git \
fetch \
--verbose \
--tags \
--prune \
"
2023-05-09 20:02:34 +00:00
# garbage collect all orphan commits
2023-05-14 14:58:37 +00:00
alias ggc="\
2023-05-14 15:08:10 +00:00
git \
reflog \
expire \
--all \
--expire \"all\" \
2023-05-14 14:58:37 +00:00
; \
2023-05-14 15:08:10 +00:00
git \
gc \
--aggressive \
2023-05-14 15:10:44 +00:00
--prune=\"now\" \
2023-05-14 14:58:37 +00:00
"
2023-05-09 20:02:34 +00:00
# initialize a new repository
2023-05-14 20:18:05 +00:00
alias gi="\
git \
init \
"
2023-05-09 20:02:34 +00:00
# initialize a new bare repository
2023-05-14 20:18:05 +00:00
alias gib="\
git \
init \
--bare \
"
2023-05-09 20:02:34 +00:00
# log commits history
2023-05-14 20:47:03 +00:00
alias gl="\
git \
log \
--all \
--graph \
--format=\"%C(auto)%h%d %C(red)%ai%C(auto) %an%n%B\" \
"
2023-05-09 20:02:34 +00:00
# log medium information
2023-05-14 20:47:03 +00:00
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 \
"
2023-05-09 20:02:34 +00:00
2023-05-14 20:29:47 +00:00
# abort the current merge commit
alias gma="\
git \
merge \
--abort \
"
2023-05-09 20:02:34 +00:00
# do a merge commit
2023-05-14 20:29:47 +00:00
alias gmc="\
git \
merge \
--no-ff \
2023-05-18 11:51:20 +00:00
--message \
2023-05-14 20:29:47 +00:00
"
2023-05-09 20:02:34 +00:00
2023-05-14 20:29:47 +00:00
# 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 \
"
2023-05-09 20:02:34 +00:00
# squash a branch and index its modifications
2023-05-14 20:29:47 +00:00
alias gms="\
git \
merge \
--squash \
"
2023-05-09 20:02:34 +00:00
# merge via external tool
2023-05-14 20:29:47 +00:00
alias 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 \
"
2023-05-09 20:02:34 +00:00
# tag a commit and sign
2023-05-14 16:07:01 +00:00
alias gts="\
git \
tag \
--sign \
"