Skip to content

Why use --git-dir?

Hello there

  • I found that when executing SafeCmd,gitaly appends --git-dir to the args

https://gitlab.com/gitlab-org/gitaly/-/blob/master/internal/git/command.go#L43

  • But in this doc, it tell me use git -C <path> if i just want to run git as if it was started in
  • I found that in a bare repo, the results obtained by using git -c <path> shortlog and git --git-dir shortlog are very different

cd path and run git shortlog is same as git -c <path> shortlog

  • I don't know which one is right

Can someone help me resolve this question?

Thanks!


Reopen

I found another place, about command git rev-parse

If the HEAD in the repo points to a reference that does not exist,

--git-dir and -C will cause different output

2021-02-01_11-35-59屏幕截图

This seems to be a git problem, but gitaly's processing may cause unexpected exceptions

https://gitlab.com/gitlab-org/gitaly/-/blob/master/internal/gitaly/service/ref/refs.go#L203

Edited by SURA
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information