How do I show the changes which have been staged?

It should just be: –cached means show the changes in the cache/index (i.e. staged changes) against the current HEAD. –staged is a synonym for –cached. –staged and –cached does not point to HEAD, just difference with respect to HEAD. If you cherry pick what to commit using git add –patch (or git add -p), –staged will return what is staged.

git-diff to ignore ^M

GitHub suggests that you should make sure to only use \n as a newline character in git-handled repos. There’s an option to auto-convert: Of course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works … And then convert your files: core.autocrlf is described on the …

Read more

How can I see the changes in a Git commit?

To see the diff for a particular COMMIT hash, where COMMIT is the hash of the commit: git diff COMMIT~ COMMIT will show you the difference between that COMMIT‘s ancestor and the COMMIT. See the man pages for git diff for details about the command and gitrevisions about the ~ notation and its friends. Alternatively, …

Read more

How to compare files from two different branches

git diff can show you the difference between two commits: Or, equivalently: Note you must specify the relative path to the file. So if the file were in the src directory, you’d say src/myfile.cs instead of myfile.cs. Using the latter syntax, if either side is HEAD it may be omitted (e.g., master.. compares master to HEAD). You may also be interested in mybranch…master (from git diff documentation): This form is …

Read more

How can I see the differences between two branches?

You want to use git diff. Where <commit> is your branch name, the hash of a commit or a shorthand symbolic reference For instance git diff abc123…def567 or git diff HEAD..origin/master That will produce the diff between the tips of the two branches. If you’d prefer to find the diff from their common ancestor to test, you can use three dots instead of two: …

Read more