Andy Wenk - 02.10.2009
This is a note to myself how to create a git repository. I am assuming to have root access to an own server. In this case it's (again) a Debian Linux machine with running Lenny.
The clone, pull and push process uses ssh, so it is necessary to create keys. Use rsa instead of dsa because it's more secure. And don't forget to set a passphrase!
On the local machine
$ ssh-keygen -t rsa
Put the public key the machine you will place the git repositorys and add them to the authorized_keys
$ aptitude install git-core
Here all the repos go in
$ mkdir /var/lib/git
A new repository
$ mkdir /var/lib/git/therepo
$ cd /var/lib/git/therepo/
$ git init
Initialized empty Git repository in /var/lib/git/therepo/.git/
Unless one file is in the repository, you cannot clone it
$ vi README
$ git add README
$ git commit README
Created initial commit fb17959: initialize
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
Change the rights for the repo to an existing user
$ chown -R myuser:users /var/lib/git/therepo
Install git
$ aptitude install git-core
Setup some global info
$ git config --global user.name "My Name"
$ git config --global user.email "[email protected]"
Add the origin
$ git remote add origin ssh://[email protected]/var/lib/git/therepo
Now clone the repo. You can set a new repo name. If not, the remote repo name will be used to create a folder.
$ git clone ssh://[email protected]/var/lib/git/therepo [local_repo_name]
Initialized empty Git repository in /home/user/git/therepo/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Start to do some work and add them to your local repo.
$ touch testfile
$ git add testfile
$ git commit tesfile
Created commit f0ed9ad: testfile
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 testfile
Here you added some files to the repo and commited them to your local branch - not to the remote branch! To do this step, you have to push them. Remember that we set the origin allready.
$ git push origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 247 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To ssh://[email protected]/var/lib/git/therepo
fb17959..f0ed9ad master -> master
If you want to recieve the actual repo or just want to check if everything is update here, use git pull.
$ git pull
Already up-to-date.
That's it - have fun with git!