1

I am facing a weird issue during git rebase

I have a branch called Networkconfigs with two commits like C1 & C2, Now I want to rebase with master. conflicts are raising only on top of C1 changes. I am unable to see C2 changes during conflict resolution.

command used for rebase at Networkconfigs: git rebase master branch Networkconfigs At C1 commit I have a file : Sample.txt At C2 commit I have replace the Sample.txt with Result.txt 

during conflict resolution I can see the Sample.txt in Networkconfigs instead of Result.txt. But If I switched Networkconfigs C2 changes are present(i.e Result.txt existed)

git log -5 --graph --oneline NetworkConfigFiles * df3acf356 (origin/NetworkConfigFiles, NetworkConfigFiles) additional changes * d7bb7a5dc Incorporate the review comments * 5243f782f create Network config files * fb372f921 Incrementing build version to 2.0.2495.0 ***NO_CI*** * 89ce8a232 Incrementing build version to 2.0.2494.0 ***NO_CI*** 

conflicts are raising w.r.t 5243f782f

2
  • can you run git log -5 --graph --oneline NetworkConfigs, and paste the output of that command ? (you can edit the messages or names you don't want to show in a public post on StackOverflow as you like, I'm mostly interested in the graph part) Commented Jan 13, 2023 at 11:07
  • git log -5 --graph --oneline NetworkConfigFiles * df3acf356 (origin/NetworkConfigFiles, NetworkConfigFiles) additional changes * d7bb7a5dc Incorporate the review comments * 5243f782f create Network config files * fb372f921 Incrementing build version to 2.0.2495.0 NO_CI * 89ce8a232 Incrementing build version to 2.0.2494.0 NO_CI Commented Jan 13, 2023 at 11:24

1 Answer 1

1

Rebase changes are applied one at a time in an orderly fashion so if C2 is after C1 in history (actually, if C1 is listed first in the rebase... given that their order can be shuffled around if using interactive), sure, you won't see C2's changes on HEAD until you have gone over applying C1 changes.

Suppose your branches look like this right now:

A <- B <- C <- D <- E <- F <- (main) ^ \- G <- H <- I <- (some-branch) 

Now, suppose that you run this:

git checkout some-branch git rebase main 

That will mean that G, H and I (or equivalents, rather) will be on top of F, right? But it's not like magic happens. Git has to apply changes one at a time, so.... if there are conflict when applying H, and you take a look at the branch that you are on at the moment, you will find that it looks like this:

A <- B <- C <- D <- E <- F <- G' <- (HEAD) ^ ^ | \- (main) \- G <- H <- I <- (some-branch) 

Notice how on HEAD, I is not applied yet, so do not expect to see code from that commit where you are standing.

Sign up to request clarification or add additional context in comments.

2 Comments

So I need to rebase C1 first then after C2 is it?
Let me explain a little bit better in the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.