Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see the change during a 'merge conflict' in git rebase

Tags:

git

I delete a file in my working directory. And then I do a 'git pull'. Another person in my team modify the same file and 'git push' to the HEAD.

So when I do a 'git rebase', I get a merge conflict something like 'CONFLICT git (delete)'

My question is how can I find out what changes did the another person in the team made to the file I 'delete'?

Thank you.

like image 328
n179911 Avatar asked Sep 30 '09 06:09

n179911


People also ask

How do you view merge conflicts?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .


2 Answers

When there is conflict during a merge or rebase, different versions of a file are available from:

  • respective branches:

    $ git show HEAD:path/to/file
    $ git show branch:path/to/file
    
  • as stages 1, 2, 3 in the index:

    $ git ls-files --unmerged  
    # ...
    $ git show :1:path/to/file
    $ git show :2:path/to/file
    

There are also tools such as "git diff --cc" and "git log --merge".

See documentation for details.

like image 180
Jakub Narębski Avatar answered Oct 20 '22 16:10

Jakub Narębski


Git keeps a copy of the state of upstream branches in your repository as "remote tracking" branches. If you do a git branch -r you will see a list of all remote branches. Choose the one that corresponds to the branch you're working on, and do something like:

git diff HEAD^..origin/master

This should show you changes between your HEAD parent (assuming your delete was the last commit, modify as necessary) and the current state of the upstream branch.

like image 21
Greg Hewgill Avatar answered Oct 20 '22 16:10

Greg Hewgill