git merge conflict - where is the history

Viewed 44

When I was rebasing, I got merge conflict. Then I do the manual fix and then git add; git rebase --continue,

but new conflict keep coming up, prompt hint: Use 'git am --show-current-patch' to see the failed patch

so I show-current-patch to see

index 1hash..8hash 100644
--- a/path/file
+++ b/path/file
@@ -1,5 +1,6 @@

+import lib

@@ -11,7 +12,7 @@ project_id = something
 with models.DAG(
 
-    start_date=datetime.datetime(2022, 1, 31),
+    start_date=airflow.utils.dates.days_ago(0),

But if I edit the file in conflict, it is like

<<<<<<< HEAD
start_date=airflow.utils.dates.days_ago(1)
=======
start_date=airflow.utils.dates.days_ago(0)
>>>>>>> other guy's commit

seems the head content is different from git am --show-current-patch?

I just couldn't figure out where is the value "1" in airflow.utils.dates.days_ago(1) coming from?

Any ideas? Thanks a lot.

1 Answers

Here are two steps when running git rebase master from branch feature (*) :

# before rebase:
*--M--x--y--z <-master
    \
     a--b--c--d <- HEAD, feature

# during rebase, when about to apply commit 'c':
          master
            v
*--M--x--y--z--a'--b' <- HEAD
    \
     a--b--c--d <- feature

When replaying commit c :

  1. the patch being applied is the diff between b and c
  2. but conflicts may arise because of changes in x, y, z, a' or b'

If a conflict happens :

  • the patch in 1. will appear as "theirs" ("other guy's commit")
  • "ours" will come from "HEAD", and that part does not appear in 1.

If you want to view what brought the changes in "HEAD", you can inspect git log -p, or use git blame.


(*) or, similarly, if you are running git format-patch --stdout master..feature | git am to apply the changes from feature on top of master

Related