Olá, meu nome é Sergeyev Sergey aka gurugray... Atualmente sou a Mentor FrontEnd Community do ManyChat. Você poderia ter visto minhas palestras sobre o ciclo de lançamento e as regras para trabalhar com sistemas de controle de versão na Yandex School of Interface Development (SRI).
Muitas vezes me perguntam quais hacks de vida ou melhores práticas eu uso ao trabalhar com Git e repositórios de projeto.
— , . -, .
1.
. — . .
> git --version
git version 2.27.0
2.
email . , GitHub , .
> git config --global user.email "gurugray@yandex.ru"
> cd company_project
> git config user.email "gurugray@manychat.com"
vim' , :
> git config --global core.editor "code --wait"
3. autocomplete
, . , .
Git , shell, , — .
4.
(aliases) . - , ssh — , ( , ). — , , .
Git SVN, , "b" — .
> git config --global alias.st "status -sb"
> git config --global alias.co "checkout"
> git config --global alias.ci "commit -a"
> git config --global alias.b "branch"
5.
— , , . . Git :
> git log --oneline --graph --branches
, , --pretty=format:
:
> git log --graph --date=short --branches --pretty=format:'%C(yellow)%h%C(reset) %ad | %C(75)%s%C(reset) %C(yellow)%d%C(reset) [%an]'
6.
, git+ssh , http :
> git clone git@github.com:gurugray/gurugray
7.
«» ( , pull-request' ) upstream
push' origin
. , , ssh-, :
> git clone git://github.com/gurugray/gurugray -o upstream
8.
pull, . , , . , :
> git fetch --all
> git rebase my_feature upstream/master
9.
, , :
> git fetch --all
> git checkout -b my_feature upstream/master
> git branch -D master
10.
, --fixup=
> git commit -m "Feature A is done"
> ...
> git commit -m "Feature B is done"
> git commit --fixup=fe2f857
> git log --oneline
a5050e7 fixup! Feature A is done
633e33f Feature B is done
...
fe2f857 Feature A is done
cb5db88 Previous commit
11.
— , «» , :
> git config --global alias.fixlast "commit --all --amend --no-edit"
12.
rebase
--autosquash
--fixup
, , guidline', pull-request' .
> git rebase -i --autosquash cb5db88
pick fe2f857 Feature A is done
fixup a5050e7 fixup! Feature A is done
pick 733e2ff Feature B is done
> git log --oneline
633e33f Feature B is done
...
5778cbb Feature A is done
cb5db88 Previous commit
13.
reset
, - «» :
> git reset @~4
> git commit --all
14. push
, --force
-f
, :
> git push origin +feature
15.
reflog
- — , :
> git reflog
> ...
> git reset --hard FOUND_HASH
, .
Git' , .