tom‎ > ‎

git server setup

On CentOS 6 Linux x86_64, the default package manager has git and gitweb.  Both were installed on indy. 

 On indy, anywhere, like in my  home directory, I first create and initialize a git repository, like this:
 
 mkdir indygit
 cd indygit
 git init
 vim a.txt
 echo "a" >> a.txt
 git add a.txt
 git commit
 cd ../
 
 On indy, I make a "bare repository" of my initialized repository, so that I can share it on this server, like this:
 
 git clone --bare --shared indygit /var/lib/git/indygit.git
 
 Those steps are the ONLY thing needed to setup a git server serving your new repository.  
 
 Afterwards, users with accounts can clone your repository, like this:
 
 git clone USER@indy.sdmgenetics.pitt.edu:/var/lib/git/indygit.git
 cd indygit
 cat a.txt
 
 Notice that a new directory was created, named "indygit", with all of the stuff inside.  All of the stuff inside 
 is now in a new local branch called "master":
 
 git branch
 
 The working directory is unrelated to the remote branch, named "origin/master":
 
 git remote -v
 
 Now you can edit, stage and commit a modification:
 
 vim a.txt
 git add a.txt
 git commit
 
 But all of that happens locally.  Push these changes to the server:
 
 git branch
 git push origin master
 
 The 'git push origin master' pushes your current branch (master) to the 'master' branch on the remote named 'origin'
 As long as no other updates have come to the server, those changes will get pushed.  Sometimes you'll need to 
 get everything-on-the-server-that-I-don't-already-have, like this:
 
 git fetch origin
 
 But that modifies origin/master...NOT your local master branch.  To bring your local copy up to date, merge it:
 
 git branch
 git merge origin/master
 
 That 'git merge origin/master' causes your local 'master' branch to merge in the most recent stuff you fetched from the server. 
 
 Now that you are up-to-date (and as long as more updates don't arrive at the server), you are again ready to modify/stage/commit:
 
 vim a.txt
 git add a.txt
 git commit
 git branch
 git push origin master





Comments