-
Notifications
You must be signed in to change notification settings - Fork 1
/
xamb.txt
30 lines (30 loc) · 2.18 KB
/
xamb.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
The Treeish
Besides branch heads, there are a number of shorthand ways to refer to particular objects in the Git data store.
These are often referred to as a treeish.
Any Git command that takes an object – be it a commit, tree or blob – as an argument
can take one of these shorthand versions as well.
I will list here the most common, but please read the rev-parse command
(http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html)
for full descriptions of all the available syntaxes.
You can always list out the entire SHA-1 value of the object to reference it.
This is sometimes easy if you’re copying and pasting values from a tree listing or some other command.
Just about anything you can reference with the full SHA-1 can be referenced fine with the first 6 or 7 characters.
Even though the SHA-1 is always 40 characters long,
it’s very uncommon for more than the first few to actually be the same.
Git is smart enough to figure out a partial SHA-1 as long as it’s unique.
Anything in .git/refs/heads or .git/refs/tags can be used to refer to the commit it points to.
This example would refer to the value of that branch yesterday.
Importantly, this is the value of that branch in your repository yesterday.
This value is relative to your repo – your ‘master@{yesterday}’ will likely be different than someone else’s,
even on the same project,
whereas the SHA-1 values will always point to the same commit in every copy of the repository.
This indicates the 5th prior value of the master branch.
Like the Date Spec, this depends on special files in the .git/log directory that are written during commits,
and is specific to your repository.
This refers to the Nth parent of that commit.
This is only really helpful for commits that merged two or more commits – it is how you can refer to a commit other than the first parent.
The tilde character, followed by a number, refers to the Nth generation grandparent of that commit.
To clarify from the carrot, this is the equivalent commit in caret syntax:
This points to the tree of that commit.
Any time you add a ^{tree} to any commit-ish, it resolves to its tree.
This is very helpful for referring to a blob under a particular commit or tree.