Created
September 28, 2022 00:02
-
-
Save anthonyaxenov/d9632d8b80b58e35a277161a32a8e696 to your computer and use it in GitHub Desktop.
My favourite global .gitconfig with aliases (ru comments)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
# ... | |
# signingkey = <key> | |
# git config user.signingkey ... -- установить ключ | |
[commit] | |
gpgSign = true | |
[tag] | |
gpgSign = true | |
[push] | |
default = current | |
[pull] | |
default = current | |
rebase = false | |
[core] | |
editor = nano | |
autocrlf = input | |
[remote "origin"] | |
prune = true | |
[include] | |
path = path/to/git_aliases # смотри ниже |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
# общее ----------------------------------------------------------------- | |
init = init -q # no blm! | |
aliases = config --get-regexp '^alias' # показать список доступных алиасов | |
user = config --local --get-regexp '^user' # локальные настройки пользователя git | |
guser = config --global --get-regexp '^user' # глобальные настройки пользователя git | |
user-me = "!git config user.name 'Anthony Axenov'; git config user.email 'anthonyaxenov@gmail.com'; git config user.signingkey 'F7CCD4EC'" | |
# ветки ------------------------------------------------------------------- | |
bheads = branch -vv # ветки и их последние коммиты | |
branches = branch --list -vv # показать текущую ветку в общем списке локальных веток | |
# br = status -sb # показать название текущей ветки | |
brd = branch -D # удалить ветку локально | |
brod = "!git branch -D "$1"; git push origin :"$1";" # удалить ветку локально и на origin | |
merged = branch --merged # показать список веток, слитых в текущую | |
#ghpr = "!git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1" # github: встать на PR с указанным id | |
# удалить локальные ветки, слитые в текущую: | |
trim = "!DEFAULT=master; git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs git branch -d; git remote prune origin;" | |
# переключение ------------------------------------------------------------ | |
co = checkout # переключиться на ветку/тег/коммит | |
cob = checkout -b # создание новое ветки | |
master = "!git checkout master && git pull" # переключиться на ветку master и обновить | |
dev = "!git checkout dev && git pull" # переключиться на ветку dev и обновить | |
develop = "!git checkout develop && git pull" # переключиться на ветку develop и обновить | |
# фиксация изменений ------------------------------------------------------ | |
c = commit # коммит | |
ca = commit -a # коммит всех файлов | |
cm = commit -m # коммит с заданным сообщением | |
cam = commit -am # коммит всех файлов с заданным сообщением | |
amend = commit --amend --no-edit -a # прикрепляет все индексированные файлы к последнему коммиту, используя уже существующее сообщение | |
#amenda = commit --amend --no-edit | |
amendm = commit --amend -m # прикрепляет все индексированные файлы к последнему коммиту, спрашивает новое сообщение к коммиту | |
cp = cherry-pick # применить коммит поверх текущего HEAD | |
diffc = diff --cached # показать дельту staged-файла | |
# управление изменениями, сброс состояний, откат -------------------------- | |
# st = status -sb # короткий status | |
st = status # сокращение | |
rh = reset --hard # откат коммита с удалением всех изменений на указанный коммит | |
rhh = reset --hard HEAD # откат коммита с удалением всех изменений на последний коммит | |
rmh = reset --mixed HEAD # откат коммита с сохранением всех изменений | |
unstage = reset HEAD # переводит файл staged => unstaged без потери изменений | |
clear = checkout -- # удаляет изменения в файле | |
# алиасы для временной фиксации | |
# на самом деле, для таких дел надо использовать git stash | |
# save = !git add -A && git commit -m 'SAVEPOINT' | |
wip = commit -am "WIP" | |
wipa = commit --amend -am "WIP" | |
undo = reset --mixed HEAD~ | |
# работа с remote-репами -------------------------------------------------- | |
pushf = push --force # отправить ветку принудительно | |
pusht = push --tags # отправить теги | |
pushft = push --tags --force # отправить теги принудительно | |
pullf = pull --force # получить ветку принудительно | |
pullt = pull --tags # получить теги | |
pullft = pull --tags --force # получить теги | |
ploh = pull origin HEAD # получить текущую ветку из origin | |
remotes = remote -v # показать список удалённых репозиториев | |
#sy = remote update origin --prune # | |
rso = remote show origin # показать состояние локальных веток относительно удалённых на origin bare | |
rpo = remote prune origin # удалить все мёртвые ссылки на bare-ветки origin | |
repush = 'git push origin :$1 && git push origin $1' # замена push --force | |
# просмотр логов ---------------------------------------------------------- | |
head = log -1 HEAD # показать последний коммит в текущей ветке | |
heads = log --graph --decorate --simplify-by-decoration --oneline # коммиты, которыми оканчиваются ветки | |
# название текущей ветки или тега при detached head: | |
dehead = "!BR=$(git branch --show-current); if [ -n \"$BR\" ]; then echo $BR; else git describe --contains --all HEAD; fi;" | |
tree = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset' | |
hist = log --pretty=format:\"%h | %an (%ad) %s%d\" --graph --date=relative | |
logfull = log --graph --decorate --all | |
grog = log --graph --decorate --all --pretty=format:'%C(bold red)%h%C(reset) %C(bold blue)%an%C(reset) %C(green)%cr%C(reset) [%aD]%d%n%B' | |
# сабмодули --------------------------------------------------------------- | |
sub = submodule # сокращение | |
# si = submodule init # инициализация сабмодулей | |
# sdi = submodule deinit -f # удаление сабмодуля | |
# sa = submodule add # добавление сабмодуля | |
# sup = submodule update # обновление сабмодуля | |
# sst = submodule status # статус сабмодулей | |
# ss = submodule summary # список сабмодулей |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment