Akhil Sharma
Akhil Sharma

Reputation: 151

Others changes in git diff

  1. I am working on a local branch. I made the changes and committed them.

  2. Now, I did a git pull (after setting upstream) and then git rebase -i.

  3. Now, if I see git diff HEAD^, I see some other changes in the file apart from my changes in the file. I think these changes are already pushed by somebody (since if I copy my file elsewhere and do git checkout and paste my file, then I see my changes only in git diff)

So, now if I do a git push, those changes will go as part of my commit.

Can someone help me to remove those changes so that the git diff shows only my changes without doing copy and checkout?

Upvotes: 1

Views: 105

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522762

What you are observing is what should be expected from doing a git rebase. Let's assume that the remote and local branches started out looking like this:

remote: A -- B -- C
              \
local:         D

Next, you made a new commit to the local branch, leaving the diagrams looking like this:

remote: A -- B -- C
              \
local:         D -- E

When you did git rebase -i on the remote branch, you brought in the C commit from the remote. Here is what the diagram looks like after the rebase:

remote: A -- B -- C
                   \
local:              D' -- E'

The changes about which you are worrying come from the C commit, and are already on the remote. Look closely, and you will see that this local branch can now fast-forward the remote.

So you don't need to worry about these mysterious changes coming in. They were probably made by your coworkers and they are already a part of the remote branch.

Upvotes: 1

Related Questions