问题描述:

I'm trying to merge in some files, but get:

#added by them: sass/main.scss

Since I've also added this file, I'd like to look at 'theirs' and see what they've done on it.

I've tried git diff sass/main.scss but this doesnt work.

Would anyone know the correct way of doing this?

网友答案:

For any file with conflict, you can check the different versions with:

git show :1:aFile
git show :2:aFile
git show :3:aFile

That is:

  • Stage #1: common ancestor of the files,
  • stage #2: target-branch version,
  • Stage #3: version you are merging from.
网友答案:

The easiest way to view a file is to open it in your favorite text editor. Since the file was "added by them", you already know that the diff is the entire file.

I've tried git diff sass/main.scss but this doesnt work.

git diff sass/main.scss compares the given file with the index. If you have already merged and not made any changes then the diff will be empty. (I assume this is what you mean by "doesn't work.") To see a diff with your work, you need to specify a commit-ish to compare with. For example

$ git diff HEAD~ -- sass/main.scss
相关阅读:
Top