2

It is ok to push to gitlab repositories directly, from outside gitlab?

Mainly what I would like to know is: * would gitlab detect changes? * is is safe, as in if it will not break repos due to concurrency?

sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

2

If I understand your question correctly you're asking whether it is possible to push commits from another git client than Gitlab to a Gitlab instance.

There's no problem at all concerning this, actually this is exactly what git and Gitlab is about.

It doesn't matter at all which Git client you use to get your commits done and pushed to the server running Gitlab. Think of Gitlab as just one possible frontend to your repositories.

If you are interested in the technical background:

Git is completely file-based and doesn't rely on any kind of central server managing your repositories. All relevant data is stored in the .git subdirectory of your project. This enables the use of multiple clients with a single repository - for example git and Gitlab.

Gitlab internally uses the gem gitlab_git which itself uses the library rugged that provides Ruby bindings for libgit2. That library is also used in the implementation of other git clients, "including the GitHub.com site, in Plastic SCM and also powering Microsoft's Visual Studio tools for Git".

Regarding the handling of actual concurrency problems, have a look at this answer by kan. Correct permissions are handled via git hooks as was kindly pointed towards in this comment below by Ciro Santilli.

Community
  • 1
  • 1
bfncs
  • 10,007
  • 4
  • 32
  • 52
  • 2
    Correct. Notes: 1) GitLab automatically symlinks your repository hooks to: https://github.com/gitlabhq/gitlab-shell/tree/master/hooks . It is those hooks that to the permission checking throuh an API call to `/internal`. So you will still get permission checks if you push directly. 2) gitlab_git uses a mix of rugged and grit not, but it is moving to rugged. – Ciro Santilli OurBigBook.com Oct 21 '14 at 09:42
  • GIT repos used by gitlab are stored on NFS shares so they could be modified by another server that has write access to NFS. Not that it would be something we have to, but we want to know if it could work. – sorin Oct 21 '14 at 09:52
  • You shouldn't have any problem with concurrency in this case as pointed out above. Since permissions are implemented via hooks, you should be ok, too. That said, a rogue (or thoughtless) user could for sure mess up your repositories badly via NFS. Thus offering access only via http/Gitlab and SSH should be preferred because they both offer a much *cleaner* interface. – bfncs Oct 21 '14 at 09:59
  • Note 2: gitlab caches some repo data on Redis to serve it faster, but not on the DB. Then the post receive hook updates the cache: https://github.com/gitlabhq/gitlab-shell/blob/823aba63e444afa2f45477819770fec3cb5f0159/hooks/post-receive#L13 – Ciro Santilli OurBigBook.com Oct 21 '14 at 10:12