Git版本控制
本文最后更新于:2022年7月14日 上午
Git 各区域命令
工作区
git clonegit initgit addgit pullgit pushgit fetchfetch到FETCH_HEADgit checkoutgit loggit reflog本地所有变更(checkout,reset^HEAD)的日志git config/statusgit status
版本库
stage
git resetgit checkoutgit stash (apply)暂存/还原git rmgit statusmastergit branchgit mergegit diffgit remotegit rebasegit reset
SSH
SSH key
生成key并保存到指定位置
ssh-keygen -t rsa -b 4096 -C "xxx@gmail.com"Host配置
# ~/.ssh/config
Host github1
HostName github.com
User SiynMa
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gmail
Host github2
HostName github.com
User SiynMa2
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_qqmail多SSH Host密钥对使用
- 分别使用两个密钥clone
git clone git@github1:JedWatson/classnames.git git clone git@github2:JedWatson/classnames.git - 配合remote别名
git remote rename github.com github1
开发中断
git stashgit reset --hard headgit checkout -- <file>
.gitignore配置
- https://github.com/github/gitignore
- https://www.gitignore.io
- 新增被追踪的ignore文件
# 清除之前的快照 git rm --cached -r . # 更新快照 git add .