Since Linus said we’re all morons ’cause we use Subversion and the like, lots of people started to migrate to his new faster, better, stronger, cooler and geekier revision control system Git.
Installation for Subversion morons like me
Get the latest stable source from http://git.or.cz/
wget http://kernel.org/pub/software/scm/git/git-18.104.22.168.tar.gz tar xzf git-22.214.171.124.tar.gz cd git-126.96.36.199.tar.gz make prefix=/usr/local all sudo make prefix=/usr/local install
Create your own little repo
mkdir moron cd moron git init
Congrats, you just created your first Git repo!
Most common commands looks like Subversion ones.
commit. But you gotta remember that there’s no such thing as a working copy in Git. It’s a distributed revision control system. Which means that your local copy is a repository. In fact, with Git you do not checkout (in the Subversion sense) a copy of the repo, you clone it. That’s why Git is so much faster. Most of the commands: history browsing, local commits, reverting, etc, are done locally, without talking to the server. Check the official guide for Subversion morons.
Try adding a file:
echo "I'm no longer a moron Linus" > moron-no-more.txt git commit -a
-a ensures that all new files are added, you can do this manually with the
git add command.
You then commit you change as you would do in Subversion, with the difference that it’s all done locally:
git commit -m "Take that Linus!"
All is not lost for us poor Subversion mortals
The cool thing about Git is it has builtin support for playing nicely with Subversion. Which ease the migration and can even let you use Git side by side with Subversion. So you can import a Subversion branch like this:
git svn init http://repo/url/trunk git svn fetch
You Git repo now has all the revisions of you Subversion branch. Try running
You can even send you changes back to Subversion:
git svn dcommit
Create your central repo
mkdir mah-repow.git cd mah-repow.git git --bare init-db git-repo-config remotes.origin.url http://yourhostname.com/git/mah-repow.git/; # notice trailing slash! git-update-server-info
Upload that directory to your public server. Like Subversion, Git supports various ways of serving a remote repo, I chose WebDAV because it’s the simpler one on DreamHost.
To send your changes to the server with Git you
push your changes to the server and
pull changes from others. With our previous examples, to push a series of commits to the server you’d do:
git repo-config remotes.origin.url http://yourhostname.com/git/mah-repow.git/; # once to setup the default server url git push