git

Referring to the branch of the current working directory with unstaged changes as a branch


It is often useful to use the HEAD keyword in git commands to refer to the last commit of the active branch.

What I am curious about is whether there is such a keyword for the working directory, which includes possible modification on top of HEAD, like unstaged changes (without having to commit these changes, obviously).

For example, I often like to view the difference between two branches using git difftool BRANCH BRANCH2, where I know that the order of BRANCH, BRANCH2 that I put in that command will point my diff tool to whether I should look left or right of the difftool GUI to see the changes in a specified branch (in the order I specified). That is why I would see the usefulness of heaving such a "WORKING_DIRECTORY_HEAD".

Is there such a thing, or something similar that would fit my needs? I realize that doing git difftool BRANCH (specifying only one branch) would actually do exactly what I want (comparing BRANCH to the WORKING_DIRECTORY_HEAD), but I just always forget the order it uses and which changeset is on the right or the left of the GUI in this case, so I would rather prefer if I had a keyword to refer to that WORKING_DIRECTORY_HEAD so I can specify the order on my own.


Solution

  • I don't think there's a commit-ish way to specify "my dirty working tree". The possibilities are described in git help revisions.

    However, you can control which side of the diff is which even without that, just using

    git diff HEAD
    

    or

    git diff -R HEAD