Git version management to resolve conflicts

First cloned branches:

:git clone https://github.com/LLLUZHAO/Test.git
正克隆到 'Test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
展开对象中: 100% (3/3), 完成.

Create a new branch and switching to new branches:

:cd Test
:git branch zhaolu
:git checkout zhaolu
切换到分支 'zhaolu'
:git branch
  master
* zhaolu
:cat 1
:cat << EOF > 1
> lurongming
> EOF

Look at the difference between the work area and temporary area:

:git diff
diff --git a/1 b/1
index e69de29..8c7346e 100644
--- a/1
+++ b/1
@@ -0,0 +1 @@
+lurongming

Workspace with the latest local repository difference:

:git diff HEAD
diff --git a/1 b/1
index e69de29..8c7346e 100644
--- a/1
+++ b/1
@@ -0,0 +1 @@
+lurongming

Staging area with the latest local repository difference:

:git diff --cached

no difference.

Add the new changes to the staging area:

:git add .

Look at the difference between the work area and temporary area:

:git diff

no difference.

Workspace with the latest local repository difference:

:git diff HEAD
diff --git a/1 b/1
index e69de29..8c7346e 100644
--- a/1
+++ b/1
@@ -0,0 +1 @@
+lurongming

Staging area with the latest local repository difference:

:git diff --cached
diff --git a/1 b/1
index e69de29..8c7346e 100644
--- a/1
+++ b/1
@@ -0,0 +1 @@
+lurongming

commit:

:git commit -m add\ lurongming .
[zhaolu 8eefe88] add lurongming
 1 file changed, 1 insertion(+)
:git log
commit 8eefe88caa3314d3422d45e2a90de9dddd1a75c2 (HEAD -> zhaolu)
Author: zhao <[email protected]>
Date:   Thu Mar 12 15:29:10 2020 +0800

    add lurongming

commit 79e6fbed4a4736a898049665ded3b96304434278 (origin/master, origin/HEAD, master)
Author: zhao <[email protected]>
Date:   Tue Mar 10 03:50:54 2020 +0800

    create

Switched to the main branch:

:git checkout master
:cat << EOF > 1
> zhaolu
> EOF
:git add .
:git commit -m add\ zhaolu .
[master e8b84ca] add zhaolu
 1 file changed, 1 insertion(+)
:git log
commit e8b84cad2c857e507a0ae54a2b572d9ca7d256a5 (HEAD -> master)
Author: zhao <[email protected]>
Date:   Thu Mar 12 15:32:05 2020 +0800

    add zhaolu

commit 79e6fbed4a4736a898049665ded3b96304434278 (origin/master, origin/HEAD, zhaolu2)
Author: zhao <[email protected]>
Date:   Tue Mar 10 03:50:54 2020 +0800

    create

Well, switch to zhaolu branch and then merge:

:git merge master
自动合并 1
冲突(内容):合并冲突于 1
自动合并失败,修正冲突然后提交修正的结果。
:git status
位于分支 zhaolu
您有尚未合并的路径。
  (解决冲突并运行 "git commit")
  (使用 "git merge --abort" 终止合并)

未合并的路径:
  (使用 "git add <文件>..." 标记解决方案)

	双方修改:   1

修改尚未加入提交(使用 "git add" 和/或 "git commit -a"

Conflict.

View File 1:

:cat 1
<<<<<<< HEAD
lurongming
=======
zhaolu
>>>>>>> master

Git marked with <<<<<<<, =======, >>>>>>> the contents of different branches, we save modified as follows:

:cat 1
hello world
:git status
位于分支 zhaolu
您有尚未合并的路径。
  (解决冲突并运行 "git commit")
  (使用 "git merge --abort" 终止合并)

未合并的路径:
  (使用 "git add <文件>..." 标记解决方案)

	双方修改:   1

修改尚未加入提交(使用 "git add" 和/或 "git commit -a":

Modified using git add 1:

:git add 1
:git status
位于分支 zhaolu
所有冲突已解决但您仍处于合并中。
  (使用 "git commit" 结束合并)

要提交的变更:

	修改:     1

Use git commit:

:git commit
[zhaolu 534144c] Merge branch 'master' into zhaolu
:cat 1
hello world

Note that the master branch into zhaolu branch.

The contents of the master branch of the same, zhaolu branch is the content of the revised conflict, to switch to the master branch look at the contents:

:git checkout master
切换到分支 'master'
您的分支领先 'origin/master' 共 1 个提交。
  (使用 "git push" 来发布您的本地提交)
:cat 1
zhaolu

Or the original content.

Published 119 original articles · won praise 5 · views 10000 +

Guess you like

Origin blog.csdn.net/LU_ZHAO/article/details/104819777
Recommended