Information Technology Reference
In-Depth Information
$ git diff --staged
Called with two revisions, git diff compares the files in these revisions:
$ git diff master beta
The additional parameter --unified can be used to specify the number of un-
changed lines that will be printed.
Recipes 13-2 to 13-7 presented various problems concerning line endings. Because
git is a tool that synchronizes the work of a group of developers and because every de-
veloper can use a different platform, you have to be aware of possible issues that may
complicate the work of your team.
The first item discussed was how to commit and how to checkout the files exactly as
they are, without any conversions performed by git. These matters, covered in Recipes
13-2 and 13-3, are essential in cases when you have problems with your line endings
and you want to get rid of them. Remember, that to get a clean checkout, you can re-
move the tracked files:
$ git ls-files | xargs rm
and the staging area:
$ rm .git/index
The command $ git reset --hard recreates the working directory and the
staging area using the snapshot stored in HEAD .
Recipes 13-4 and 13-5 explain in greater detail the procedures you should follow if
you want to commit the files with the line endings converted to CRLF and LF, respect-
ively.
Recipe 13-6 presents an anti-pattern that should convince you how important line
endings are. When followed, it will produce the following error: even though no files
were edited, git reports them as all changed. If any developer commits and submits this
type of change it will confuse other developers. And, by the way, the $ git diff
command also can be helpful when dealing with problems concerning white characters,
line endings in particular. When called with --check parameter:
$ git diff --check
Search WWH ::




Custom Search