git的使用
发现自己还是各种记不住,所以还是用到什么命令就记下来如下:
git init
git status
git diff <filename>
- 尚未缓存的改动:
git diff
- 查看已缓存的改动:
git diff --cached
- 查看已缓存的与未缓存的所有改动:
git diff HEAD
- 显示摘要而非整个diff:
git diff --stat
- 尚未缓存的改动:
git add .
或git add -A
以及git add <filename>
git commit -m "some description"
git commit -am "some description"
git remote add origin <server>
git push origin <branch_name>
git checkout -- <filename>
- branch的使用
- 创建一个叫做“feature_x”的分支,并切换过去:
git checkout -b feature_x
- 切换分支:
git checkout <branch_name>
- 删除分支:
git branch -d <branch_name>
git push origin <branch>
- 创建一个叫做“feature_x”的分支,并切换过去:
- 更新与合并
- 更新本地仓库至最新改动:
git pull
- 合并其他分支到你的当前分支:
git merge <branch>
如果有冲突,手动改文件并且git add <filename>
git commit -m "some description"
git diff <source_branch> <target_branch>
- 更新本地仓库至最新改动:
- ssh key的使用
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh -o StrictHostKeyChecking=no [email protected]