Domanda

I'd like to set up a git repository on one of our servers that's accessible to certain users. We're using Stash as out git host, and only users with a Stash key are able to push. I'd like to have our local code in a location accessible to everyone on the box (/data/repo) and allow authorized users to make changes and push them back to Stash as themselves (not as a service account). How do I have user-specific git settings in a public repo?

È stato utile?

Soluzione

We're using this setup because the code in the git repo is uploaded to our Chef server. This shared repo will be used by our ops folks to pull down releases from the master branch of our git repo, then upload them to chef server. They were concerned about the case where one ops user changes a file and uploads it to chef without committing it to git. When another ops user pulls from master and uploads to chef, those changes can be lost (chef server doesn't deal with conflicts at all). To avoid that, they will all work in the same directory, so anything changed will be marked as conflicted by git in this case.

I've worked out how this is done.

Repo settings:

<git clone command, creates folder 'repo'>
chmod -R g+rw repo
chmod g+s `find repo -type d
cd repo
git config core.sharedRepository true

These settings mark the repo as shared, and set anything new created in the repo as belonging to the user's group.

User settings:

cd ~
git config --global user.name <name>
git config --global user.email <email>

The --global flag creates ~/.gitconfig. Multiple users can work in the shared repo and any git commands will reference this file. I've tested this with 2 users. Anything modified is visible to all. Commits can be signed by each user, and when someone pushes all committed changes are pushed with their author info intact.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top