-1

I am trying to squash the following commits 1,2,3,4 and 5. The rests of the commits are comming from the a merge of develop branch with my branch. I used the following command line:

git rebase -i d3c5321cbc3 (which is the commit right under 1f65fc141cd)

pick 1f65fc141cd WHERE I WANT TO SQUASH
s 881d49fe757 commit1
s 9c02d893697 commit2
s 6e146d89daa commit3
[...]
s fa4b6c3805e commit4
s 65f4969bc8f commit5
pick 8017df05f67 commit6
pick 31391e4d1d3 commit7
[...]

I don't understand why I am getting a dead code. And how can I fix it?


Error

enter image description here

Community
  • 1
  • 1
gringo
  • 373
  • 2
  • 4
  • 15
  • Have you tried doing what the message said, and checking for / resolving conflicts...? That isn't Git telling you to "Remove dead code"; it's Git saying that's the commit message of `2baaae7ca72`, which is the commit causing the issue. You can `git diff` the work tree to see why, and then edit/add/continue the rebase to resolve it. – underscore_d Jun 18 '20 at 14:32
  • @underscore_d Thank you for the question. I actually asked the question because I got so angry for having to fix the merge conflicts. the files where I got the conflicts are not mine. Why Is Git forcing me to do that? – gringo Jun 18 '20 at 14:34
  • Because it can't just guess what should happen if other devs have changed things in the same/near location as you... they wouldn't be very happy if it just made a call about how to make your changes 'win' and erased their work and broke the codebase, for example. – underscore_d Jun 18 '20 at 14:34

1 Answers1

2

I don't understand why I am getting a dead code. And how can I fix it?

The error message is a bit confusing, what you see is in fact a Git conflict (see this post of this post) and Remove dead code is simply the commit message associated with commit 2baa... which cannot be rebased because of said conflict.

You do not have a "dead code" issue, that's simply some message associated to the conflicting commit.

You should:

  • Resolve the conflict locally
  • Run git rebase --continue once conflict is solved
Pierre B.
  • 11,612
  • 1
  • 37
  • 58
  • what If i delete all the other lines with the pick ? – gringo Jun 18 '20 at 14:55
  • That's a choice you have to make depending the code you want to keep or not. A conflict mean that the branch you are trying to rebase on and your branch made conflicting changes on some file - you should either keep your changes, keep the other changes, or adapt the code to "merge" both of your changes – Pierre B. Jun 18 '20 at 14:59