Skip to content

Commit 3a6b211

Browse files
committed
dev/git: About git pull and rebase
1 parent 33f4612 commit 3a6b211

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/dev/git.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,20 @@ git checkout feature
393393
git rebase master
394394
```
395395

396-
通过如下设置,可以使得 `rebase` 成为默认行为
396+
如果你或者你的团队对线性历史有需求,通过如下设置,可以使得 `rebase` 成为 `git pull` 时候的默认行为。这样可以防止与其他人在同一分支合作时,出现大量的 merge commit
397397

398398
```ini
399399
[pull]
400400
rebase = true
401401
```
402402

403+
或者也可以限制 `git pull` 只能进行 fast-forward,在出现分叉时用户可以手动 `git pull --rebase`,或者使用其他解决的方式:
404+
405+
```ini
406+
[pull]
407+
ff = only
408+
```
409+
403410
!!! question "更新一个有修改的本地仓库"
404411

405412
以下是一个现实的例子:某个代码 git 仓库(存储在 GitHub 上)的 `master` 分支部署在一台服务器上,并且在该服务器上不仅做了一些额外的 commit 用来记录一些服务器相关的配置,还有一些没有被 stage 的文件。现在该代码仓库在 GitHub 上的 `master` 分支有一些新的更新 commit(例如更新了依赖,修复了 bug 等),那么如何将这些 commit 部署在该服务器上呢?

0 commit comments

Comments
 (0)