Skip to content

Instantly share code, notes, and snippets.

@mtilson
Last active April 13, 2020 08:58
Show Gist options
  • Save mtilson/75691f2bc54cb5bf4d7cc3fd9ab9c9eb to your computer and use it in GitHub Desktop.
Save mtilson/75691f2bc54cb5bf4d7cc3fd9ab9c9eb to your computer and use it in GitHub Desktop.
what useful refs are inside '.git' directory, part 2 - GitHub mirrored bare repo [git]

We have only one remote

  • $ git remote
repo-to-fetch

Directory structure

  • $ tree -L 1
.
├── COMMIT_EDITMSG
├── FETCH_HEAD
├── HEAD
├── config
├── description
├── hooks
├── index
├── info
├── logs
├── objects
├── packed-refs
└── refs

'refspecs'

  • 'refspecs' can be both in packed-refs file
    • $ cat packed-refs
# pack-refs with: peeled fully-peeled sorted
  • and in refs/ directory
    • $ for i in $(find refs -type f); do echo -n $(cat $i); echo " $i" ; done
71940958cc9ebf3904119ae16c549cc23cbe6652 refs/pull/9/head
ba73b7f6a48ea8ca6373b16ca5a9d67103d12c86 refs/pull/11/head
545c6ee5e166a6fb65ad93f1fdbc284c77a535f0 refs/pull/7/head
14918306f5a5d375e553ce9ef3fb044bae275201 refs/pull/16/head
42347165778cd5640720f66fc3d4919905f84d70 refs/pull/6/head
2f27b0ffe0330565411d6b8a28f7c92f90852aca refs/pull/1/head
ce46a4519061e27250e1284523d8b3275f07248b refs/pull/10/head
042ef1b40b11cb304315c69f210ebfeb3efe5989 refs/pull/8/head
429f925d2c6476bd5cb0245417b304b37a366439 refs/pull/4/head
bd35ca81676735ddbf5ccdbfbd8f86f6d9423e13 refs/pull/15/head
f96c6c3ebc5819cf7561acd6c439b5989522765a refs/pull/3/head
617ab4449a6a5796bc05f4d9374d1a57caf3577c refs/pull/12/head
66d6dff9328982649dfdf3d56e629ede660a0146 refs/pull/2/head
cddbf6d94f517951e7108f655671e6b7e78e175b refs/pull/13/head
bc2c663578912c42f479934de17b40db8c6b7c51 refs/pull/5/head
b2f1492ac129f37432280f61926ff9a2089ee587 refs/pull/14/merge
6cf4610fc2b4aaa18002f3592a5cbe1161cab196 refs/pull/14/head
bb2e4197f7a43a657679aaa0431074a4c5243a34 refs/heads/gf
ce46a4519061e27250e1284523d8b3275f07248b refs/heads/user/feature10
0b2f912cc59f06cde211fab3d2e505120656edee refs/heads/user/feature13
6cf4610fc2b4aaa18002f3592a5cbe1161cab196 refs/heads/user/feature14
bb2e4197f7a43a657679aaa0431074a4c5243a34 refs/heads/greate-feature
50b3ba9f8277e04b55553b2968ff3c83c8ef1453 refs/heads/master
44eac6ac98c3c7bde5a183418ed16dee87540b57 refs/tags/v0.0.1
685234a3ba1e408df54d1ce5a9836df95346ae81 refs/tags/v0.0.6
876b83ed8fe60e9db0d543d0b9a32c630565abc3 refs/tags/v0.0.5
dfcad2cba1f1550900941d52698abf98e166c10f refs/tags/v0.0.2
6cc157a6219262b8f454db5701e2b4a7af6ec6b8 refs/tags/v0.0.3
d9de8d804d5f93ca9a757997758c15d7c12dfbfe refs/tags/v0.0.4

Local branches correspond to refs/heads/* and are 'refspecs' configured for git push

  • $ git br -vv
  gf             bb2e419 greate-feature
  greate-feature bb2e419 greate-feature
* master         50b3ba9 Merge pull request #16 from txxxx-xx/user/feature16
  user/feature10 ce46a45 feature10
  user/feature13 0b2f912 Merge pull request #13 from txxxx-xx/user/feature13
  user/feature14 6cf4610 feature14
  • $ git remote show repo-to-fetch
...
  Remote branches:
    ...
    user/feature10     stale (use 'git remote prune' to remove)
    ...
  Local refs configured for 'git push':
    gf             pushes to gf             (up to date)
    greate-feature pushes to greate-feature (up to date)
    master         pushes to master         (local out of date)
    user/feature13 pushes to user/feature13 (up to date)
    user/feature14 pushes to user/feature14 (up to date)
...
  • $ git ls-remote repo-to-fetch | grep "user/feature10"
<no output>

No local remote-tracking branch of the form refs/remotes/<remote-name>/*

  • $ git br -rv
<no output>

GitHub pull request 'refspecs' correspond to refs/pull/*/(pull|merge)

  • See details on GitHub pull request 'refspecs' here

Repo configuration is in config

  • $ cat config
...
[core]
	...
	bare = true
	...
[remote "repo-to-fetch"]
	url = https://github.com/txxxx-xx/gxx-xxxx.git
	fetch = +refs/*:refs/*
...

No local tracking branches set up in config to track remote branches

  • $ git br -vv
  gf             bb2e419 greate-feature
  greate-feature bb2e419 greate-feature
* master         50b3ba9 Merge pull request #16 from txxxx-xx/user/feature16
  user/feature10 ce46a45 feature10
  user/feature13 0b2f912 Merge pull request #13 from txxxx-xx/user/feature13
  user/feature14 6cf4610 feature14
  • $ git remote show repo-to-fetch | grep "Local branches configured for 'git pull'"
...
  <no output>
...

new remote branches are in repo-to-fetch and not in refs/*

  • $ git remote show repo-to-fetch
...
Remote branches:
    ...
    refs/pull/17/head  new (next fetch will store in remotes/repo-to-fetch)
    refs/pull/18/head  new (next fetch will store in remotes/repo-to-fetch)
    user/feature19     new (next fetch will store in remotes/repo-to-fetch)
    user/feature20     new (next fetch will store in remotes/repo-to-fetch)
    ...
  • $ git ls-remote repo-to-fetch | grep "pull/\(17\|18\)\|feature\(19\|20\)"
a11074212323a2bed2b11c31cd232fa8d03862f4	refs/heads/user/feature19
2ca50b0c10fff54b9a1c7a833940b3a15a77a47c	refs/heads/user/feature20
d1e21644be5d904183ee28f26a6393be92690ed0	refs/pull/17/head
f2fd57156013d612afc8a5d0c2659eed42ae8906	refs/pull/18/head
  • $ find refs -type f | grep "17\|18\|19\|20"
<no output>

Local branch user/feature10 is present in refs/heads/*, but absent in remote repo (mapped by remote.<name>.fetch, which is refs/*:refs/*) declared as stale by git remote show

  • $ for i in $(find refs -type f -path "refs/heads/*"); do echo -n $(cat $i); echo " $i" ; done
bb2e4197f7a43a657679aaa0431074a4c5243a34 refs/heads/gf
ce46a4519061e27250e1284523d8b3275f07248b refs/heads/user/feature10
0b2f912cc59f06cde211fab3d2e505120656edee refs/heads/user/feature13
6cf4610fc2b4aaa18002f3592a5cbe1161cab196 refs/heads/user/feature14
bb2e4197f7a43a657679aaa0431074a4c5243a34 refs/heads/greate-feature
50b3ba9f8277e04b55553b2968ff3c83c8ef1453 refs/heads/master
  • $ git ls-remote repo-to-fetch | grep "refs/heads"
bb2e4197f7a43a657679aaa0431074a4c5243a34	refs/heads/gf
bb2e4197f7a43a657679aaa0431074a4c5243a34	refs/heads/greate-feature
16600c85005bc95c4933125394b79de03d4a9e02	refs/heads/master
0b2f912cc59f06cde211fab3d2e505120656edee	refs/heads/user/feature13
6cf4610fc2b4aaa18002f3592a5cbe1161cab196	refs/heads/user/feature14
a11074212323a2bed2b11c31cd232fa8d03862f4	refs/heads/user/feature19
2ca50b0c10fff54b9a1c7a833940b3a15a77a47c	refs/heads/user/feature20
  • $ git remote show repo-to-fetch
...
  Remote branches:
    ...
    user/feature10     stale (use 'git remote prune' to remove)
    ...

Local tag 'refspecs' (refs/tags/*) mapped to remote ones (refs/tags/*) both for 'lightweight' (v0.0.1, v0.0.2, v0.0.3) and 'annotated' (v0.0.4, v0.0.5, v0.0.6) tags, but there are no dereferenced points for local ones when they are not packed

  • $ for i in $(find refs -type f -path "refs/tags/*"); do echo -n $(cat $i); echo " $i" ; done
...
44eac6ac98c3c7bde5a183418ed16dee87540b57 refs/tags/v0.0.1
685234a3ba1e408df54d1ce5a9836df95346ae81 refs/tags/v0.0.6
876b83ed8fe60e9db0d543d0b9a32c630565abc3 refs/tags/v0.0.5
dfcad2cba1f1550900941d52698abf98e166c10f refs/tags/v0.0.2
6cc157a6219262b8f454db5701e2b4a7af6ec6b8 refs/tags/v0.0.3
d9de8d804d5f93ca9a757997758c15d7c12dfbfe refs/tags/v0.0.4
...
  • $ git ls-remote repo-to-fetch
...
44eac6ac98c3c7bde5a183418ed16dee87540b57	refs/tags/v0.0.1
dfcad2cba1f1550900941d52698abf98e166c10f	refs/tags/v0.0.2
6cc157a6219262b8f454db5701e2b4a7af6ec6b8	refs/tags/v0.0.3
d9de8d804d5f93ca9a757997758c15d7c12dfbfe	refs/tags/v0.0.4
f96c6c3ebc5819cf7561acd6c439b5989522765a	refs/tags/v0.0.4^{}
876b83ed8fe60e9db0d543d0b9a32c630565abc3	refs/tags/v0.0.5
429f925d2c6476bd5cb0245417b304b37a366439	refs/tags/v0.0.5^{}
685234a3ba1e408df54d1ce5a9836df95346ae81	refs/tags/v0.0.6
06023bee3f84cf4274c368b84a53917521972e4d	refs/tags/v0.0.6^{}
...
  • $ git show 685234a3ba1e408df54d1ce5a9836df95346ae81
tag v0.0.6
Tagger: txxxx <[email protected]>
Date:   Mon Apr 6 09:54:11 2020 +0300

v0.0.6

commit 06023bee3f84cf4274c368b84a53917521972e4d (tag: v0.0.6)
Merge: 9437094 bc2c663
Author: mxxxxxx <[email protected]>
Date:   Sun Apr 5 12:27:13 2020 +0300

    Merge pull request #5 from txxxx-xx/user/feature26

    feature26

Other interesting stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment