Черновик Шпаргалки по Git

В самом начале:
git config --global user.name "John Doe"
git config --global user.email john.doe@email.com

Длинные имена файлов в Windows:
git config --global core.longpaths true

GPG
gpg --full-generate-key
Выбрать алгоритм ключа или нажать Enter для RSA and RSA
Ввести длину ключа: 4096
Ввести срок действия ключа или нажать Enter - срок действия ключа не истекает.
Ввести "y"
Ввести своё имя
Ввести свой email
Ввести комментарий или нажать Enter
Ввести "O"
Два раза ввести пароль

Добавить ключ в конфиг Git:
git config --global user.signingkey $ID

Подписывать все коммиты по умолчанию:
git config --global commit.gpgsign true

Просмотреть лог с подписями GPG
git log --show-signature

Экспорт публичного ключа:
gpg --armor --export $ID >  pub-$ID.asc

Экспорт секретного ключа:
gpg --armor --export-secret-keys $ID >  priv-$ID.asc


Add remote origin 'main':
git remote add origin git@github.com:user/repo.git
git branch -M main
git push -u origin main

Закрыть (в архив) ветку:
git tag archive/<branchname> <branchname>
git branch -D <branchname>

Восстановить закрытую ветку:
git checkout -b <branchname> archive/<branchname>

Удалить закрытую ветку:
git tag -d archive/<branchname>


Тэги (метки)
Создать тэг:
git tag v0.0.1
git push origin v0.0.1

Удалить тэг:
git tag -d v0.0.1
git push origin :refs/tags/v0.0.1

Дополнительно: здесь.


"Очистить историю" репозитория:
git checkout --orphan TEMP_BRANCH
git add -A
git commit -am "Initial commit"
git branch -D master
git branch -m master
git push -f origin master

Удалить ветку локально:
git branch -d test

Удалить ветку во внешнем репозитории:
git push origin --delete test


Git aliases:
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.unstage 'reset HEAD --'
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
git config --global alias.type 'cat-file -t'
git config --global alias.dump 'cat-file -p'
git config --global alias.last 'log -1 HEAD'

".bash_aliases" file:
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gun='git reset HEAD --'
alias ghist='git hist'
alias gco='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'

alias got='git '
alias get='git '



Github
Форматирование
Автоматические ссылки
Ссылки в pull request


Семантическое Версионирование

Комментарии

Популярные сообщения