Skip to content

Instantly share code, notes, and snippets.

@mtilson
Last active April 13, 2020 09:44
Show Gist options
  • Save mtilson/12511302a42c5a51f2809161beb612ba to your computer and use it in GitHub Desktop.
Save mtilson/12511302a42c5a51f2809161beb612ba to your computer and use it in GitHub Desktop.
what useful refs are inside '.git' directory, part 3 - special names for commits [git]
  • HEAD - pointer to the local branch you’re currently on (reference to the most recent commit in curent branch)
    • $ cat .git/HEAD
ref: refs/heads/master
  • refs/remotes/origin/HEAD - is the same type of pointer as local HEAD, but for origin remote
    • all refs/remotes/origin/* are remote-tracking branches which are local references (to the state of remote branches) that you can’t move

      • Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository
      • think of them as bookmarks, to remind you where the branches in your remote repositories were the last time you connected to them
      • git fetch <remote-name> updates your remote-tracking branches
    • for GitHub it is the “base” branch in your (remote) repository, against which all pull requests and code commits are automatically made, unless you specify a different branch

    • $ cat .git/refs/remotes/origin/HEAD

ref: refs/remotes/origin/master
  • ORIG_HEAD - is set to the value of HEAD before operations changing the currently checked-out commit (git merges, git reset)
    • cat .git/ORIG_HEAD
4b1ea8f65eb4911139c900605df0f6f3dbf17bf2
  • FETCH_HEAD - is set to the head of the last fetched branch by git fetch operation
    • $ cat .git/HEAD # cloned (non-bare) repo
16600c85005bc95c4933125394b79de03d4a9e02		branch 'master' of https://github.com/txxxx-xx/gxx-xxxxx
bb2e4197f7a43a657679aaa0431074a4c5243a34	not-for-merge	branch 'gf' of https://github.com/txxxx-xx/gxx-xxxxx
bb2e4197f7a43a657679aaa0431074a4c5243a34	not-for-merge	branch 'greate-feature' of https://github.com/txxxx-xx/gxx-xxxxx
0b2f912cc59f06cde211fab3d2e505120656edee	not-for-merge	branch 'user/feature13' of https://github.com/txxxx-xx/gxx-xxxxx
6cf4610fc2b4aaa18002f3592a5cbe1161cab196	not-for-merge	branch 'user/feature14' of https://github.com/txxxx-xx/gxx-xxxxx
a11074212323a2bed2b11c31cd232fa8d03862f4	not-for-merge	branch 'user/feature19' of https://github.com/txxxx-xx/gxx-xxxxx
2ca50b0c10fff54b9a1c7a833940b3a15a77a47c	not-for-merge	branch 'user/feature20' of https://github.com/txxxx-xx/gxx-xxxxx
    • $ cat .git/HEAD # mirrored bare repo
50b3ba9f8277e04b55553b2968ff3c83c8ef1453		branch 'master' of https://github.com/txxxx-xx/gxx-xxxxx
bb2e4197f7a43a657679aaa0431074a4c5243a34	not-for-merge	branch 'gf' of https://github.com/txxxx-xx/gxx-xxxxx
bb2e4197f7a43a657679aaa0431074a4c5243a34	not-for-merge	branch 'greate-feature' of https://github.com/txxxx-xx/gxx-xxxxx
ce46a4519061e27250e1284523d8b3275f07248b	not-for-merge	branch 'user/feature10' of https://github.com/txxxx-xx/gxx-xxxxx
0b2f912cc59f06cde211fab3d2e505120656edee	not-for-merge	branch 'user/feature13' of https://github.com/txxxx-xx/gxx-xxxxx
6cf4610fc2b4aaa18002f3592a5cbe1161cab196	not-for-merge	branch 'user/feature14' of https://github.com/txxxx-xx/gxx-xxxxx
14918306f5a5d375e553ce9ef3fb044bae275201	not-for-merge	branch 'user/feature16' of https://github.com/txxxx-xx/gxx-xxxxx
2f27b0ffe0330565411d6b8a28f7c92f90852aca	not-for-merge	'refs/pull/1/head' of https://github.com/txxxx-xx/gxx-xxxxx
ce46a4519061e27250e1284523d8b3275f07248b	not-for-merge	'refs/pull/10/head' of https://github.com/txxxx-xx/gxx-xxxxx
ba73b7f6a48ea8ca6373b16ca5a9d67103d12c86	not-for-merge	'refs/pull/11/head' of https://github.com/txxxx-xx/gxx-xxxxx
617ab4449a6a5796bc05f4d9374d1a57caf3577c	not-for-merge	'refs/pull/12/head' of https://github.com/txxxx-xx/gxx-xxxxx
cddbf6d94f517951e7108f655671e6b7e78e175b	not-for-merge	'refs/pull/13/head' of https://github.com/txxxx-xx/gxx-xxxxx
6cf4610fc2b4aaa18002f3592a5cbe1161cab196	not-for-merge	'refs/pull/14/head' of https://github.com/txxxx-xx/gxx-xxxxx
b2f1492ac129f37432280f61926ff9a2089ee587	not-for-merge	'refs/pull/14/merge' of https://github.com/txxxx-xx/gxx-xxxxx
bd35ca81676735ddbf5ccdbfbd8f86f6d9423e13	not-for-merge	'refs/pull/15/head' of https://github.com/txxxx-xx/gxx-xxxxx
14918306f5a5d375e553ce9ef3fb044bae275201	not-for-merge	'refs/pull/16/head' of https://github.com/txxxx-xx/gxx-xxxxx
66d6dff9328982649dfdf3d56e629ede660a0146	not-for-merge	'refs/pull/2/head' of https://github.com/txxxx-xx/gxx-xxxxx
f96c6c3ebc5819cf7561acd6c439b5989522765a	not-for-merge	'refs/pull/3/head' of https://github.com/txxxx-xx/gxx-xxxxx
429f925d2c6476bd5cb0245417b304b37a366439	not-for-merge	'refs/pull/4/head' of https://github.com/txxxx-xx/gxx-xxxxx
bc2c663578912c42f479934de17b40db8c6b7c51	not-for-merge	'refs/pull/5/head' of https://github.com/txxxx-xx/gxx-xxxxx
42347165778cd5640720f66fc3d4919905f84d70	not-for-merge	'refs/pull/6/head' of https://github.com/txxxx-xx/gxx-xxxxx
545c6ee5e166a6fb65ad93f1fdbc284c77a535f0	not-for-merge	'refs/pull/7/head' of https://github.com/txxxx-xx/gxx-xxxxx
042ef1b40b11cb304315c69f210ebfeb3efe5989	not-for-merge	'refs/pull/8/head' of https://github.com/txxxx-xx/gxx-xxxxx
71940958cc9ebf3904119ae16c549cc23cbe6652	not-for-merge	'refs/pull/9/head' of https://github.com/txxxx-xx/gxx-xxxxx
44eac6ac98c3c7bde5a183418ed16dee87540b57	not-for-merge	tag 'v0.0.1' of https://github.com/txxxx-xx/gxx-xxxxx
dfcad2cba1f1550900941d52698abf98e166c10f	not-for-merge	tag 'v0.0.2' of https://github.com/txxxx-xx/gxx-xxxxx
6cc157a6219262b8f454db5701e2b4a7af6ec6b8	not-for-merge	tag 'v0.0.3' of https://github.com/txxxx-xx/gxx-xxxxx
d9de8d804d5f93ca9a757997758c15d7c12dfbfe	not-for-merge	tag 'v0.0.4' of https://github.com/txxxx-xx/gxx-xxxxx
876b83ed8fe60e9db0d543d0b9a32c630565abc3	not-for-merge	tag 'v0.0.5' of https://github.com/txxxx-xx/gxx-xxxxx
685234a3ba1e408df54d1ce5a9836df95346ae81	not-for-merge	tag 'v0.0.6' of https://github.com/txxxx-xx/gxx-xxxxx
  • MERGE_HEAD - refers to the other branch that we’re merging in to the current branch by merging operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment