Git+中文教程(19)

时间:2026-01-20

Git+中文教程

Git 中文教程

$ git push :/pub/scm/git/git.git/

将工作捆绑到一起

通过 git 的分支功能,你可以非常容易地做到好像在同一时间进行许多“相关-或-无关”的工作一样。

我们已经通过前面的 "fun and work" 使用两个分支的例子,看到分支是怎么工作的。这样的思想在多于两个的分支的时候也是一样的,比方说,你现在在 master 的头,并有些新的代码在 master 中,另外还有两个互不相关的补丁分别在 "commit-fix" 和 "diff-fix" 两个分支中。

$ git show-branch

! [commit-fix] Fix commit message normalization.

! [diff-fix] Fix rename detection.

* [master] Release candidate #1

---

+ [diff-fix] Fix rename detection.

+ [diff-fix~1] Better common substring algorithm.

+ [commit-fix] Fix commit message normalization.

* [master] Release candidate #1

++* [diff-fix~2] Pretty-print messages.

两个补丁我们都测试好了,到这里,你想将他们俩合并起来,于是你可以先合并 diff-fix ,然后再合并 commit-fix,像这样:

$ git merge 'Merge fix in diff-fix' master diff-fix

$ git merge 'Merge fix in commit-fix' master commit-fix

结果如下:

$ git show-branch

! [commit-fix] Fix commit message normalization.

! [diff-fix] Fix rename detection.

* [master] Merge fix in commit-fix

---

- [master] Merge fix in commit-fix

+ * [commit-fix] Fix commit message normalization.

- [master~1] Merge fix in diff-fix

+* [diff-fix] Fix rename detection.

+* [diff-fix~1] Better common substring algorithm.

* [master~2] Release candidate #1

++* [master~3] Pretty-print messages.

Git+中文教程(19).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:4.9 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:19元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219