Skip to content

GitLab Under the Hood Users in Git, Gitolite and GitLab

riyad edited this page Oct 23, 2012 · 2 revisions

This is meant to clarify what different pieces in the GitLab machinery consider a "user" and how they are linked together.

Git

When creating a commit, Git will only use the name and email settings from your local system.

# for the current repo only (overrides the global setting)
git config user.email "[email protected]" --local
git config user.name "Your Name" --local

# general setting for all your repos
git config user.email "[email protected]" --global
git config user.name "Your Name" --global

Git will create a commit and fill in the author and committer information accordingly (this is just meta data for a commit, you can't really "enforce" anything here).

Gitolite and SSH

Once you are happy with your local changes you push them to GitLab. To be able to push changes to GitLab you have to have a user with the necessary privileges. Also you have to create a key pair on your local machine and associate the public key with the GitLab user through the web interface (add as many keys per user as you want, but don't use any key twice or for different users).

GitLab uses Gitolite for repository and access management behind the scenes. Which in turn configures your system (in form of the UNIX user called git) to accept incoming SSH connections (aka pushes) from computers who authenticate themselves with the appropriate key. (that's why you have *git*@your-domain.tld/... clone URLs 😉) Once the SSH connection is established, Gitolite takes control and makes sure the "GitLab user" the given key belongs to, has the appropriate permissions to push to the repository. Once Gitolite is OK with it, it lets Git take over and actually starts transferring data. (Don't worry, this all happens in the background)

It is important to note, that Git can transport anything over an established connection. This means, that you could merge stuff on your computer and then also push "other peoples' commits" to GitLab. At no point is it enforced that the "authorship information" (of the commit) match the "GitLab user". (It would be silly, knowing the way Git works and is meant to be used)

GitLab and the Web

Once your push is done, your commits will show up on the GitLab web interface. When displaying commits GitLab will look at the committer and author information and will try to find a GitLab user with that name or email address and link to his/her profile. If the commit author does not have an account on your GitLab instance (as with external contributors) it will just display the infos found in the commit.

Clone this wiki locally