Difference between revisions of "Git"
import>Jss43 m |
import>Ajwt3 (Git useful information) |
||
Line 78: | Line 78: | ||
</pre> |
</pre> |
||
This is very useful (especially as git encourages branching so much!). |
This is very useful (especially as git encourages branching so much!). |
||
+ | |||
+ | == Subversion migration using git == |
||
+ | |||
+ | Thanks to http://linuxocarina.blogspot.com/2008/07/using-git-svn-migrate-svn-repository.html |
||
+ | |||
+ | My project is to take an SVN repository Cambridge on server cam and SVN repository Berkeley on server berk and allow changes back and forth between the two. |
||
+ | Cambridge is the initial repository, and we will create Berkeley from it (Berkeley is an initialized and blank SVN repository directory). Both Berekeley and Cambridge will be indepenedently |
||
+ | modified, and the aim is to keep the two in sync via git. |
||
+ | |||
+ | First, we must create the Berekeley respository from the Cambridge |
||
+ | |||
+ | (Thanks to http://linuxocarina.blogspot.com/2008/07/using-git-svn-migrate-svn-repository.html) |
||
+ | |||
+ | e.g. starting in /git : |
||
+ | <pre> |
||
+ | git-svn clone svn://cam/Cambridge Cambridge |
||
+ | git clone file:///git/Cambridge Berkeley |
||
+ | cd Berkeley |
||
+ | git-svn init svn://berk/Berkeley |
||
+ | git-svn fetch |
||
+ | git rebase git-svn master |
||
+ | git-svn dcommit |
||
+ | </pre> |
||
+ | |||
+ | --[[User:ajwt3|alex]] 07:21, 6 August 2008 (BST) |
Revision as of 06:21, 6 August 2008
git is the second project that Linus Torvalds has named after himself. It is now on the workstation image.
git is a distributed version control system (DVCS), which offer many advantages over centralised version control systems such as subversion. For git in particular:
- Ability to use version control without the internet access required to access the wwmm server. I now have the complete history of our code on my laptop. No wifi needed! :-). It also means I can do sequential commits without needing internet access.
- Branching and merging are *easy* and *lightweight*. This has changed how I work...
- git-svn provides an interface (in both directions) with a subversion repository. This means that we get all the advantages of using subversion (a centralised server which is backed up and maintained by someone other than us, subversion is installed on more systems, can work with people who are using subversion and don't want to change) with none of the disadvantages (subversion makes branches an absolute pain, especially if you want to just try something out and have a play without polluting the server). The interface is so slick, that I can use git and everyone else use subversion and not know that I'm using git (but I may have just let the cat out of the bag on that one).
- It's fast.
- It doesn't screw around with my history or lose files.
- It's cryptographically secure. (This isn't as bizarre as it sounds!)
- Linus Torvalds is much smarter than us. Seriously. Oh, and he calls everyone using subversion (and cvs) stupid. Repeatedly. He managed to convince me...
It is somewhat less user friendly in places, but far more powerful, than subversion. It has wonderful graphical interfaces for viewing branches (gitk and qgit).
Things I really miss when I have to use svn:
- stash.
- branching and merging.
- tab completion on the subcommands (e.g. git commit and svn commit) and a PS1 containing the branch information (see below).
- git diff plays nicely with graphical diffs (svn is meant to, but good luck on getting it working with xxdiff).
Useful links
git-svn links
meld and git diff
Set up git diff to use meld or xxdiff rather than outputting a unified diff by adding, e.g.,
[diff] external = meld
to ~/.gitconfig.
Unfortunately git tries to pass more information than xxdiff or meld can handle. Instead add:
[diff] external = ~/bin/diff.sh
to ~/.gitconfig where ~/bin/diff.sh contains:
#!/bin/bash meld $2 $5
and enjoy graphical diff wonderland.
Cool things
Add tab completion for the git subcommands: completion script. Follow the instructions within to set up tab completion. It also contains a handy function that adds the current branch to your PS1. I added:
PS1='\u@\h:\w$(__git_ps1 " [%s]")\$ '
to my .bashrc. This only adds something when I am in a git-controlled directory. If I change directories, it remembers what branch I am in:
james@maruchon:~/work/src$ cd CPMD-NECI james@maruchon:~/work/src/CPMD-NECI [master]$ git branch * master test james@maruchon:~/work/src/CPMD-NECI [master]$ git checkout test Switched to branch "test" james@maruchon:~/work/src/CPMD-NECI [test]$ cd NECI/ james@maruchon:~/work/src/CPMD-NECI/NECI [master]$ git branch exp * master james@maruchon:~/work/src/CPMD-NECI/NECI [master]$ git checkout exp cd -Switched to branch "exp" james@maruchon:~/work/src/CPMD-NECI/NECI [exp]$ cd - /home/james/work/src/CPMD-NECI james@maruchon:~/work/src/CPMD-NECI [test]$ git checkout master Switched to branch "master" james@maruchon:~/work/src/CPMD-NECI [master]$ cd NECI/ james@maruchon:~/work/src/CPMD-NECI/NECI [exp]$ git checkout master Switched to branch "master" james@maruchon:~/work/src/CPMD-NECI/NECI [master]$ cd james@maruchon:~$
This is very useful (especially as git encourages branching so much!).
Subversion migration using git
Thanks to http://linuxocarina.blogspot.com/2008/07/using-git-svn-migrate-svn-repository.html
My project is to take an SVN repository Cambridge on server cam and SVN repository Berkeley on server berk and allow changes back and forth between the two. Cambridge is the initial repository, and we will create Berkeley from it (Berkeley is an initialized and blank SVN repository directory). Both Berekeley and Cambridge will be indepenedently modified, and the aim is to keep the two in sync via git.
First, we must create the Berekeley respository from the Cambridge
(Thanks to http://linuxocarina.blogspot.com/2008/07/using-git-svn-migrate-svn-repository.html)
e.g. starting in /git :
git-svn clone svn://cam/Cambridge Cambridge git clone file:///git/Cambridge Berkeley cd Berkeley git-svn init svn://berk/Berkeley git-svn fetch git rebase git-svn master git-svn dcommit
--alex 07:21, 6 August 2008 (BST)