Show Nth version of FILE before head:
git show HEAD~N:FILE
At the local machine, create bare cahckout and copy to server:
git clone --bare ~/path-to-project/datasci datasci.git scp -r datasci.git tyr.diku.dk:GIT/
Anyone with ssh access ca then clone the repo with:
git clone tyr.diku.dk:GIT/datasci.git
What you need to know to use Git to track a little project and look at old revisions:
# start git in directory git init # track some files git add *odp # commit some revisions git commit -a -m'save' # ... # show history for file git log 08-lecture_1.odp # log contains for example this: # # commit f829e113d4ac848408a2c310180656465f3ae579 # Author: pink <pink@localdomain.(none)> # Date: Mon Sep 22 08:19:21 2008 +0200 # # save # fetch that specific revision of file: git show f829e:08-lecture_1.odp > f829e.odp
Note that git command can be written as git-command, e.g. git show can be written as git-show.
The preceeding works on one machine. If you want to use a "central" repo to hold all the changes done on clients you can do as follows. Let's call the host with the master for M and the client used in the former example C1 (with the repo in local-git) and another client C2.
First we have to create the repo at M. If there is an ssh-server at C1, this is a one-step operation, as we can log in to M and clone directly from C1:
# make "central" master on M as a copy of a local repo from C1 # (where git-rep is a choosen name, also note: this requires an ssh server at C1) # on M: git-clone --bare C1:local-git git-rep
Otherwise we will have to use rsync first to make a local copy at M:
# make a local cop with rsync on M from C1 # on C1: rsync -va local-git M:/tmp/ # this results in a /tmp/local-git on M # now we can make the clone locally on M: git-clone --bare /tmp/local-git git-rep
We can now clone local copies from M (this corresponds to a checkout in cvs/svn):
# clone to C2 from M: # on C2: git-clone M:git-rep/ some-local-dir
Changes on C1 can be pushed to the master (this corresponds to a commit in cvs/svn). Remember you have to commit them locally first:
# after some local changes committed with git-commit # on C1: git-push --all M:git-rep/
And the changes pulled on another client:
# now we can pull the changes made on C1 into the repo at C2, # on C2: git-pull plan:git-rep/
In short: you use clone to do a checkout/copy and push/pull to commit/update from the master. You could also use git as a distributed system and clone and push/pull directly between clients.