0%

git配置笔记

Git的一个配置笔记,方便查询用

绑定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 秘钥生成

ssh-keygen -t rsa -C "钥匙名"

# 绑定账户

git config --global user.name “your_username” # 设置用户名
git config --global user.email “your_email” # 设置邮箱

# 连接验证, `坑: 是直接回车还会输入yes?`

ssh -T [email protected] # coding
ssh -T [email protected] # github
ssh -T [email protected] # oschina

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 你的英文名

git config --global user.name

# 你的邮箱

git config --global user.email

# Push 哪个分支(选择一个)

git config --global push.default matching # push 所有分支
git config --global push.default simple # push 当前分支

# 设置提交信息不被转义

git config --global core.quotepath false

# 设置默认编辑工具

git config --global core.editor "vim" 编辑工具

提交

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 新建目录

mkdir git-demo

# 进入目录

cd git-demo

# 初始化

git init

# 添加到本地缓存

git add 文件

# 提交到本地仓库

git commit -m '提交信息'

# 添加远程仓库

git remote add origin 仓库名

# 远程仓库拉取

git pull

# 提交远程仓库

git push -u origin master # 再次提交只需要git push

其它

1
2
3
4
5
6
7
8
9
git remote add origin [email protected]:xxxxxxx.git 将本地仓库与远程仓库关联
git remote set-url origin [email protected]:xxxxx.git 上一步手抖了,可以用这个命令来挽回
git branch 新建分支
git merge 合并分支
git stash 通灵术
git stash pop 反转通灵术
git revert 后悔了
git reset 另一种后悔了
git diff 查看详细变化

看不懂时

拿走 explainshell.com