You just installed git. Now it’s time to set it up. First, you want to set up your name and email, which will be added to your commits:
$ git config --global user.name "Your Name" $ git config --global user.email name@email.com
Another useful option is alias. We can also use the command line to set it or we can edit ~/.gitconfig:
[alias] st = status
This means we can just type git st instead of git status. As you get more familiar with git, you’ll want to add your own aliases.
Check the manual for the complete list of options.
Change gitk fonts
Gitk looks bad. Really bad. We can improve it by changing the default font. You need to edit ~/.gitk:
set mainfont {Monaco 10}
set textfont {Monaco 10}
set uifont {Monaco 10}
Much better.
Bash completion
Lookup contrib/completion in the git source directory. Git-completion.bash includes the instruction to set it up. You need to copy that file somewhere and source it in your ~/.profile. Once this is done, you can press tab to complete git commands, options and the name of branches in bash. The script also adds __git_ps1 which you can use in your PS1 to include the name of the current branch in your bash prompt. Because you will use branches with git, it can help you remember that you switched branch just before leaving work the day before.
Popularity: 43% [?]
Note: These instructions are for Mac OS 10.4. I don’t know if they’ll work with Leopard.
Installing git is easy, just compile from the source. Git svn is harder to install because it is a bunch of perl scripts that needs the svn perl bindings (it comes with git btw). Here are the steps I recommend to make sure everything works.
First, we’ll install git using Macports. This will take care of installing all the required perl libraries:
$ sudo port install git-core +svn
However, macports installs a slightly old version of git. So I suggest downloading the latest and compiling from source.
$ sudo make install # Note: watch out for the way your PATH is setup # to make sure you are using this new git version # instead of the macports version $ git --version
Now if you try to run git svn, you might get an error about it not finding SVN/Core.pm. That means your version of subversion does not include the perl bindings (which is the standard if you installed svn with macports). I suggest you install subversion from this package that includes the language bindings. Now you need to add this to your ~/.profile:
export PERL5LIB=/usr/local/lib/svn-perl
Everything should work. Now it’s time to import your svn repositories and enjoy git.
Popularity: 29% [?]
I’ve been using git for three months now and it has had zero impact on my team. They weren’t even aware I was using it for the first few weeks. That means, you can start using it now, for your personal development, without having to convince anybody.
Git comes with a svn wrapper. You can import your svn repository to a local git repository. You then get all the advantages of git: easy branching/merging, offline operation(very useful if you work with a laptop), etc.
$ git svn clone http://path/to/svn -T trunk -t tags -b branches
This command will import all the revisions from svn and create branches in your git repository (one for trunk, and one for all your branches). You will be on a branch master (linked to trunk) and can start working. You commit normally to your repository.
When you are ready to send your changes back to svn:
$ git svn rebase # (equivalent to svn update) $ git svn dcommit # (equivalent to svn commit)
Rebase works by reverting your changes, getting the latest revisions from svn, and then reapplying your changes. You resolve any conflicts (if there any). The last command then pushes your changes to svn for your team to enjoy.
Those are the three commands you need to know to use git with svn.
Caveats
Svn:externals are not supported. I suggest you use piston to handle them.
Check out the git svn docs for a few more things to watch out for.
Conclusion
Now that your team has seen you using git successfully for weeks, it will be much easier to get them to switch!
Popularity: 20% [?]
Rails developers will switch to Git because just like Rails is ten times better than any java( or .Net) framework, git is ten times better than subversion.
I will be presenting git at the next Montreal On Rails. You may want to wait for my presentation to switch to git, but that means going a whole month without benefitting from git’s awesomeness. So here are a couple of links to get you started:
- Linus Torvalds presentation on git at Google: You NEED to listen to this talk to change the way you look at source control and understand why git rocks so much. Linus is great and funny in this talk. Warning: he will call you stupid.
- Peepcode screencast on git: Peepcode rules and this screencast will show you how to use git. It costs 9$, but if you were at the last Montreal on Rails, you should have a special code to get one screencast for free.
- Using Git to Manage and Deploy your Rails Apps: Here’s another screencast that will walk you through setting up a new rails project using git, setting up a git server and then deploying with capistrano (capistrano 2.1 supports git for deployment).
- Setting up a new Rails app with Git and Setting up a new remote git repository: two excellent and detailed walkthrough.
- Why distributed version control: Very good explanation of the advantages of git.
- Using Git for core development and Using GIT for Rails Development: Two other very good tutorials.
- Git tutorial and git svn tutorial, two tutorials from the official site.
That should be enough to get you started. Make sure you listen to Linus’ talk. It’s one hour long, but it’s definitely worth it.
Popularity: 28% [?]