On Mon, 20 Feb 2017 20:42:58 -0800 (PST)
AD S <a...@radianweb.com.au> wrote:

> Both myself and someone else have added the same file and so when
> I've tried to push my file to a remote repo, I get the error `added
> by them: styles.scss`.
> 
> I want to inspect 'their' file to see how it differs from mine. Is
> there a way I can view that file with the command line?

It's possible.

To cite `git help revisions`:

| :<n>:<path>, e.g. :0:README, :README
|     A colon, optionally followed by a stage number (0 to 3) and
| a colon, followed by a path, names a blob object in the index at the
| given path. A missing stage number (and the colon that follows it)
| names a stage 0 entry. During a merge, stage 1 is the common ancestor,
| stage 2 is the target branch’s version (typically the current branch),
| and stage 3 is the version from the branch which is being merged.

When a merge conflict happens, the entry in the index for the file with
an active conflict actually points at the several versions of the
content of that file, called "stages".

When you just want to see the contents of a non-conflicting file as
recorded in the index, you do

  git show :path/to/that/file

and that simple ':' actually gets interpreted to mean ":0:" as in

  git show :0:path/to/that/file

The "theirs" version of an index entry which records the state of a
file in conflict is 3, so to see "theirs" version, you do

  git show :3:path/to/that/file

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to