File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -629,11 +629,19 @@ git remote set-url origin new_url_of_repo
629
629
```
630
630
631
631
#### 3.3.2 推送本地仓库
632
- - 使用` push ` 推送本地内容到远程仓库` origin ` 的` master ` 分支,第一次使用建议加` -u ` ,这会将本地的` master ` 分支和远程的` master ` 分支关联起来,在以后的` push ` 或者` pull ` 时就可以简化命令
632
+ - 在` push ` 本地内容到远程前,应当先` fetch ` 或` pull ` 拉取远程仓库对应分支的超前于本地分支的新提交内容,前者只拉取而不立刻合并到本地对应分支,后者则默认相当于先` fetch ` 再` merge ` 远程分支,这会产生一条新的提交记录,若洁癖而不想这样则有以下两种方法避免产生新提交记录
633
+ - 方法一:先使用` fetch ` 拉取分支,再使用` git rebase ` 将本地分支变基到远程分支上,而非采取` merge ` 合并
634
+ - 方法二:或通过以下指令设置` pull ` 默认执行` rebase ` 而非` merge ` ,以避免方法一的两次操作之麻烦
635
+
636
+ ```
637
+ git config --global pull.rebase true
638
+ ```
639
+
640
+ - 使用` push ` 推送本地` master ` 分支内容到远程仓库` origin ` 的` master ` 分支(若使用` -u ` 参数,则会将本地` master ` 分支与远程` origin ` 的` master ` 分支关联,后续` push ` 或` pull ` 时就可以省略远程分支名,直接写` git push ` 或` git pull ` ,否则仍需写` origin master ` )
633
641
634
642
```
635
- git push -u origin master
636
643
git push origin master
644
+ git push -u origin master
637
645
```
638
646
639
647
- 在特殊情况下还可以使用强制推送用于撤回提交或者覆盖提交历史
You can’t perform that action at this time.
0 commit comments