There is a git server, I put a web interface there, and I need to tie ctags to the files. To do this, I need to process every push in hooks , I decided to make two branches on the origin repository:

  • master
  • dev

It is necessary now to somehow find out the email repository ( origin or others), and a branch, via http such information is not transmitted.

I did in the local turnip:

git checkout dev git commit -am message git push origin dev` 

after that I looked at the head file:

in .git / HEAD on client: ref: refs/heads/dev
on server ref: refs/heads/master

dev was created after master

but does HEAD essentially point to the last commit in the change tree? Why on the master server?


here still executed on the server:

 grep dev $(find . -name "*") grep: .: Это каталог grep: ./branches: Это каталог grep: ./logs: Это каталог grep: ./logs/refs: Это каталог grep: ./logs/refs/heads: Это каталог grep: ./hooks: Это каталог grep: ./objects: Это каталог grep: ./objects/48: Это каталог grep: ./objects/64: Это каталог grep: ./objects/23: Это каталог grep: ./objects/85: Это каталог grep: ./objects/0d: Это каталог grep: ./objects/c8: Это каталог grep: ./objects/a5: Это каталог grep: ./objects/5a: Это каталог grep: ./objects/c6: Это каталог grep: ./objects/4b: Это каталог grep: ./objects/50: Это каталог grep: ./objects/91: Это каталог grep: ./objects/pack: Это каталог Двоичный файл ./objects/pack/pack-382c3207511c9c58c83e7d34690c5d3615876bf0.pack совпадает grep: ./objects/45: Это каталог grep: ./objects/ab: Это каталог grep: ./objects/1f: Это каталог grep: ./objects/41: Это каталог grep: ./objects/2e: Это каталог grep: ./objects/dd: Это каталог grep: ./objects/2f: Это каталог grep: ./objects/62: Это каталог grep: ./objects/b9: Это каталог grep: ./objects/info: Это каталог grep: ./objects/ad: Это каталог grep: ./objects/30: Это каталог grep: ./refs: Это каталог grep: ./refs/tags: Это каталог grep: ./refs/heads: Это каталог grep: ./info: Это каталог ./info/refs:4869dddb814126c310e424276797f4bf0ea7540a refs/heads/dev 

That is, can the branch information be stored in a .pack file? which is essentially a hash table (archive) of the entire project.

  • "but does HEAD essentially have to point to the last commit in the change tree?" - after cloning and even more so just push - no way. - etki
  • one
    On the server with a high probability, bare repository. And in this case, the concept of "current branch" does not make sense. - KoVadim
  • @KoVadim Well, in the instructions for setting up the server, you must specify the bare repository, probably, yes. But turnips are created through the web interface and then cloned into the machine. - OlegUP
  • @KoVadim can I somehow convert it to non-bare? - OlegUP
  • one
    make a copy of the repository next to the server, where you can clone the necessary branch, do whatever you want - run ctags. And if you clone with the -l option, you can even save a lot of space. - KoVadim

1 answer 1

preliminary reminder

in git the branch ( branch ) is called the “sliding” pointer to commit , and not the commit set , as is customary in some other version control management systems.


but does HEAD essentially point to the last commit in the change tree? Why on the master server?

in the bare- repository, the HEAD file refers to the “default branch”, which primarily affects the cloning results of this repository: if during cloning it is not indicated which branch the working directory should be switched to ( working directory ) after the end of the cloning, and there will be a switch.

maybe the branch information is stored in a .pack file?

branch information is stored in the refs/heads directory. in the repository described by you, there must be at least two master and dev files containing a hash of the commit, to which the corresponding branch is currently pointing.

  • I meant the information about the current branch and the repository eleyes. Can I get this information in the bare repository? - OlegUP
  • one
    if by the term “current branch” you mean a branch that is deployed in the working directory, then in the case of a bare repository it does not make sense - there is simply no working directory next to the repository . only the bare (bare) repository. - aleksandr barakin
  • I hope you already understand that you are trying to go the wrong way. Please ask a new question about how you can automate the generation of ctags, armed with the information already received. - aleksandr barakin
  • now somehow in a magical way appeared on the server / refs / heads / dev did not appear before, but HEAD still points to master - OlegUP
  • everything is correct, it says that it didn’t fit ... - Nick Volynkin