User Tools

Site Tools



Checkout Remote Branch

$ git fetch origin
$ git checkout -b test origin/test


$ vim .gitconfig

  name = XXX
  email = xx@yy.zz
  pretty = oneline
  ui = true
  s = status --short
  editor = vim                    

Basic Editing


git add FILE
git commit -m 'DESCRIPTION'


git tag TAGNAME commit-hash

Create New Branch:

git branch XXX

Switch Branch:

git checkout XXX

Delete uncommitted changes:

git reset --hard

Push To Server


1 - Create repo on server, tweak settings

$ ssh server
$ cd X
$ git init .
$ git config receive.denyCurrentBranch ignore
$ vim .git/hooks/post-receive


# Update the working tree after changes have been pushed here
cd ..
env -i git reset --hard

$ chmod +x .git/hooks/post-receive

2 - Create remote on server

$ git remote add live ssh://

3 - Push to server

$ git push live origin


Client, Client, Server Trickery

For adding remotes, etc – Don't forget to point out the protocol, i.e.


Basic Setup

Client A Client B Server Comment
adduser –home /var/git git
chown git:git /var/git
su - git
cd /var/git
mkdir proj
git init –bare . Init bare repository
cd /proj
git init .
touch README
git add README
git commit -m 'first'
git remote add origin git@server/var/git/proj Adds origin remote
git push origin master Push master to origin
git clone git@server:/var/git/proj Clone origin

Push Changes

Client A Client B Comment
git add X
git commit -m 'Y'
git push origin master
git pull

Push Other Branch

Client A Client B Comment
git checkout -b xyz Create branch xyz
git add X
git commit -m 'Y'
git push origin xyz Push branch xyz to origin
git pull origin xyz Pull branch xyz from origin
git checkout xyz Checkout branch xyz

NB: git pull does git fetch, then git merge


git.txt · Last modified: 2013/10/08 11:11 by Volker