Month: April 2009

Git set up a public repository

If you have to set up a public repository with git you can follow the instruction found on the git-core tutorial
(Hint: Search for “Publishing your work”)

Things to keep in mind:

  • Public repository are usually named as project.git and it’s a directory even if you can be mislead to think it’s a file for the extension (.git). Well, it’s not a file.
  • you need to login in the remote host (the one from which you will share your repo) and initialized a local git database:
    • ssh account compulsory
    • git should be in the path and available in the web server
  • You need an ssh account over there.
  • Then you can push your changes to the new shiny repo.

The steps to do that:

  1. login the remote <public-host>
  2. mkdir project.git
  3. GIT_DIR=my-git.git git init
  4. mv project.git/hooks/post-update.sample project.git/hooks/post-update This make sure that after every push the git update-server-info is ran and your repo can be accessed in the public way.
  5. git push <public-host>:/path/to/project.git master

Git Again – Svn Workflow

On this page on the GNOME website I found how to use git properly if you are using it as a gateway to a svn:

  1. git svn clone _svn_server_location #Clone the repository
  2. git svn fetch #Download the stuff
  3. git svn rebase #Merge the updates with the current
  4. git checkout -b myfeature #Create a local branch
  5. hack hack hack # hack
  6. git commit -am "changed stuff" # Commit
  7. hack hack hack # hack
  8. git commit -am "changed other stuff" # Commit
  9. git checkout master # Change to master branch
  10. git merge --squash myfeauture #Merge myfeature to master
  11. git commit -am "merge the feature to the master"
  12. git svn dcommit # Commit everything on the svn server

More info about git in the previous posts

Some stuff about git you should know

Git rocks, and after two days of using I can confirm it.

I was a user of bazar, but with the switching of GNOME to git and the big trouble that bazar was giving me to commit on the svn of the EBI I decided to give to git a go.

Also on bioinfoblog the match between git and bazar it’s a though one, but I right now the svn support from git just works out of the box, so I started to use it.

I want also to point out that with the last git (ATMOW) is possible to create a remote branch on the svn server with:

git svn branch mybranch

and this was one of the killer feature that made me switch.

This is not a tutorial on git but I will provide you some quick and dirty pointers to other posts that I found interesting for a quick introduction to git.

Stuff to keep in mind about git:

  • You always work in a local branch.
  • You commit locally
  • You push (or dcommit if using a remote svn repository) to the remote branch.
  • The name of a remote branch is remote/foobar and you need to put the remote prefix also if it doesn’t show up with the remote prefix not optional. You need this if you create a local branch and you want to track a remote branch.

Some pointers here:

I’ve customized my bash prompt to show my current branch on a git repository. This is the code (based on some code found on the net that I can’t track anymore.. I’m sorry….) looks like this:

#git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/'
}
#grey
PS1='[33[0;32m]u[33[1;32m]@[33[0;32m]h[33[00m]:[33[01;34m]W[33[1;30m]$(parse_git_branch)[33[00m]$ '

The terminal looks like this
git prompt