前提
建立一个新分支
$ git switch -c feature1
修改本地的工作区test.md文件然后再次提交add到feature1分支
$ git add test.md
$ git commit -m "new simple"
现在,master分支和feature1分支各自都分别有新的提交,变成了这样:
利用status查看是否存在冲突
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: t2.md
no changes added to commit (use "git add" and/or "git commit -a")
存在冲突重新提交然后删除需要删除的内容
$ git add test.md
$ git commit -m "conflict fixed"
查看分支合并图
$ git log --graph
* commit f04f5fc5a1f52b3c50ae5a27387a8dac6d90f71b (HEAD -> master, origin/master)
| Author: matthewchen123 <ccc6687939@163.com>
| Date: Mon Jan 25 10:50:35 2021 +0800
|
| need to delete
|
* commit babd4e26cf847f2759cbc97de993d625b5312d93
| Author: matthewchen123 <ccc6687939@163.com>
| Date: Mon Jan 25 10:41:28 2021 +0800
|
| have a wrong word
|
* commit 6a9e57ac7f840f5674d641d09db914e117afaad6
| Author: matthewchen123 <ccc6687939@163.com>
| Date: Sun Jan 24 20:26:58 2021 +0800
|
| the third
|
* commit cf0cf78038378cc124e8b5ff1ed4da28a0c1445f
Author: matthewchen123 <ccc6687939@163.com>
Date: Sun Jan 24 16:03:44 2021 +0800