This post summaries the procedure for setting up a git server for small team development using private code repository. The trigger is that github does NOT provide free private repository (except student/teacher account) and we are not ready to open the code to the public. Then the most convenient way for us is using ssh to set up a git server. Once the server is ready, either IDEs, like NetBeans/Eclipse or stupid git bash shell could be used for code checking in/out.
How to set up a Git Server on a Linux machine
NOTE: our intention is to set up a private code repository
with only a few team members having the access!
Reference
http://git-scm.com/book/en/Git-on-the-Server
0. How to install git on Linux
yum install git-core (Fedora/RedHat/CentOS)
1. Protocol Analysis – (We will choose SSH)
local: for NFS filesystem based code repository
ssh: system level network protocol – read/write
git: git specific protocol – fast but no authentication
http/https: web protocol – slow but popular
2. Make a new bare repository (either LOCALLY or on the git server directly)
git clone –bare my_project my_project.git
[daveti@aimlab ~]$ git clone –bare gitserver gitserver.git
Cloning into bare repository gitserver.git…
warning: You appear to have cloned an empty repository.
[daveti@aimlab ~]$ ll
total 148
drwx—— 7 daveti daveti 4096 Sep 11 22:55 .
drwxr-xr-x 24 root root 4096 Aug 27 12:15 ..
-rw——- 1 daveti daveti 3190 Sep 11 17:23 .bash_history
-rw-r–r– 1 daveti daveti 33 Aug 27 12:15 .bash_logout
-rw-r–r– 1 daveti daveti 232 Aug 28 21:26 .bash_profile
-rw-r–r– 1 daveti daveti 124 Aug 27 12:15 .bashrc
drwxrwxr-x 2 daveti daveti 4096 Sep 11 22:48 blog
-rw-rw-r– 1 daveti daveti 29519 Aug 27 12:30 dmesg.out
-rw-r–r– 1 daveti daveti 515 Aug 27 12:15 .emacs
drwxrwxr-x 7 daveti daveti 4096 Sep 11 22:55 gitserver.git
drwxr-xr-x 3 daveti daveti 4096 Aug 27 12:15 .kde
drwxrwxr-x 3 daveti daveti 4096 Aug 28 20:53 ml
drwxr-xr-x 4 daveti daveti 4096 Aug 27 12:15 .mozilla
-rw——- 1 daveti daveti 8641 Sep 11 21:40 .viminfo
[daveti@aimlab ~]$
3. Transport the bare repository into REMOTE git server if it is generated LOCALLY
scp -r my_project.git user@git.server.example.com:/opt/git
4. Make sure ‘user’ could clone the code locally
git clone user@git.server.example.com:/opt/git/my_project.git
5. Make sure ‘user’ could push the code back to repository
touch/vi README.txt
git init
git add README.txt
git commit -m “first commit”
git push origin master
6. Other useful commands for git
git status
git log
git remote -v
7. Configure IDE for git connection
Eclipse:
http://help.eclipse.org/juno/index.jsp?topic=//org.eclipse.platform.doc.user/tasks/tasks-127.htm
NetBeans:
http://netbeans.org/kb/docs/ide/git.html
Another good thing for small team development with private code repository would be the combination below:
java.net + SVN + NetBeans(with plug-in TeamServer). It is simple and stupid:)