Setup a new git developer
I have a group setup on my computer called "git-user". My /git directory has been chgrp'd to git-user (that's important). I then setup a developer account on my machine like so:
Setup the group:
sudo addgroup git-user
Setup the user:
sudo adduser --shell /usr/bin/git-shell --ingroup git-user [username]
Of course, replace [username] with the username for the dev you want to share your repo with. You'll notice that I set their login shell to be git-shell. This is so you don't have to worry about them logging into your box and using it as a torrent seeder (or basically using it for anything other than git) Image may be NSFW.
Clik here to view.
Setup ssh keys for the user
I don't want my user to have to login with a password. For a few reasons a) I don't want to have to manage their password b) I want to make it as easy as I can for them. To have them be able to login without a password you need them to generate (if that haven't already) a public/private keyset and they must give you the public key.
To generate the keyset have them follow these steps:
ssh-keygen -t dsa -f ~/.ssh/id_dsa -C "username@emailhere.com" (note, you could use rsa as well if you are so inclined)
Have your dev send you the file that's in their ~/.ssh/ directory called id_dsa.pub (or id_rsa.pub if they chose -t rsa).
You're job will be to create a .ssh/authorized_keys file in your developers home directory, and copy the contents of that public key they sent you into it. You do that like so:
sudo mkdir /home/username/.ssh sudo chown username:username /home/username/.ssh sudo chmod 700 /home/username/.ssh sudo cat id_dsa.pub > /home/username/.ssh/authorized_keys sudo chown username:username /home/username/.ssh/authorized_keys
Setup the repo
Put your repo wherever you'd like, but it has to be reachable by users within the git-user group. So for instance I did the following:
mkdir /git sudo chgrp git-user /git
Then, to setup the repository for my project:
cd /git mkdir myproj sudo chgrp git-user myproj cd myproj git init --bare --shared=group
Note: It's worth it to mention that in some older versions of git, issuing the git init
command with the --shared=group
would not properly set the group for the "objects" directory (I believe). The version I used in this tutorial was 1.6.1.3 and it seems to work fine now.
Put code in your repo
- backup your local project somewhere
- change into the directory of your local project
- type:
git init
- type:
git remote add origin username@tataryn.net:/git/myproj
- type:
git pull origin master
ls -al
your local directory to make sure your files are still there and confirm there is a .gitignore file present- type:
git add .
- type:
git commit -a -m "initial import of my proj"
- type:
git push
The last step may or may not work, it all depends on whether you have code already in the repo at the time you originally pulled. If this doesn't work try: git push origin master