Git工具链 (new)
Apr 28, 2022
Git是目前最流行的版本管理系统,github.com也是当前最大的交友论坛,学习并使用Git已经是程序员的基本要求。
安装
命令行版本
1 | brew install git |
图形界面
SourceTree https://www.sourcetreeapp.com/
Github Desktop https://desktop.github.com/
配置使用
修改~/.gitconfig文件
1 | [user] |
修改~/.gitignore_global
1 | *~ |
常用命令
1 | git clone https://git.ubuntu.com/ubuntu.git |
rebase
1 | git rebase -i HEAD~n |
进本交互编辑界面,提示如下:
1 | pick f7f3f6d changed my name a bit |
修改后边的两个pick为squash,可以将这三个commit合为一个提交:
1 | pick f7f3f6d changed my name a bit |
netrc auto login
*** AS YOU MAY KNOWN, IT’S VERY DANGEROUS ***
1 | touch ~/.netrc |
GPG Sign
Download GPG Suite: https://gpgtools.org/
- Open
GPG Keychain - Click
Newto and follow instrctions to generate a new GPG key - Select the key you want to export and click
Export - Copy the content of exported public key, add to Github or Gitlab, if you prefer to use terminal:
gpg --armor --export pub <KEY ID> - Config Git to use your sign key id
- execute
gpg --list-secret-keys --keyid-format=long - copy sign key id from
sec ed20000/this-is-you-sign-key 2099-01-01 [SC] - execute
git config --global user.signingkey <KEY ID> - force git to sign all commit with
git config --global commit.gpgsign true
- execute
With Sourcetree GUI:
- open
preferences, underAdvencedset GPG Program, withGPG Suiteit’s/usr/local/MacGPG2/bin - for each repository, open
Repository->Repository Setting, underSecuritysection, enable GPG sign and select the right sign-key
Git托管
- Github https://github.com/
- Bitbucket https://bitbucket.org/
- GitCafe (国内) https://coding.net/
参考
- Gogs https://gogs.io
- SourceTree https://www.sourcetreeapp.com/
- Git教程 - 廖雪峰 https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
- Github GPG: https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification
- Gitlab GPG: https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/index.html
- Git merge –squash 详解: https://www.cnblogs.com/lookphp/p/5799533.html