Skip to content

Commit 62ca828

Browse files
authored
Update git.md
1 parent f087736 commit 62ca828

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

git.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,40 @@ git branch -m new-branch
4343
git pull
4444

4545
# 拉取远程仓库代码到本地其它分支
46-
git pull <remote-branch>:<local-branch>
46+
git pull origin <remote-branch>:<local-branch>
4747

48-
#
48+
# 拉取远程分支代码到本地当前分支
49+
git pull origin <remote-branch>
4950
```
5051

52+
#### 提交相关
53+
54+
```bash
55+
# 添加变更代码到暂存区(文件已被追踪)
56+
git add -u
57+
58+
# 添加所有变更到暂存区
59+
git add .
60+
61+
# 提交代码到本地仓库
62+
git commit -m 'xxxx'
63+
```
64+
65+
#### 撤回相关
66+
67+
```bash
68+
# 放弃本地的一些变更
69+
git checkout <file-name>
70+
71+
# 放弃本地所有变更
72+
git checkout .
73+
74+
# 如果已经commit了且代码还在本地仓库,想撤回commit提交,且代码还想保留
75+
git reset
76+
77+
# 代码回退到某一版本且这个版本之前的代码还想保留
78+
git reset <commit-hash>
79+
80+
# 代码回退到某一版本且以前的代码都不要了
81+
git reset --hard <commit-hash>
82+
```

0 commit comments

Comments
 (0)