study/linux/git.md
2020-02-23 22:23:40 +08:00

30 lines
867 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# git使用教程
## 常用命令
- 克隆项目
```sh
git clone git@www.zeekling.cn:deep-learn/papers.git
git clone git@www.zeekling.cn:deep-learn/papers.git location # 克隆到指定文件夹
```
- 版本回退
```sh
# 此为默认方式,不带任何参数的git reset,这种方式,它回退到某个版本,只保留源码,回退commit和index信息
git reset -mixed head file
#回退到某个版本只回退了commit的信息不会恢复到index file一级。如果还要提交直接commit即可
git reset -soft head file
#彻底回退到某个版本,本地的源码也会变成为上一个版本的内容
git reset -hard head file
```
- https保存密码
```shell
git config --global credential.helper store
```
## 常见问题
1. 添加了秘钥但是克隆项目或者提交代码的时候显示没有权限
```shell
ssh-add ~/.ssh/github
```