Git

From Jon's Wiki

Handy git configuration

Put this in your ~/.gitconfig

[alias]
    lol = log --graph --decorate --oneline
[color]
    diff = auto
    branch = auto
    log = auto
    status = auto
[push]
    default = current
[user]
    name = Harry Potter
    email = harry@hogwarts.school.uk
[core]
    autocrlf = input
    pager = less -F -X

Bung these in your ~/.bashrc

export GIT_AUTHOR_NAME='Harry Potter'
export GIT_AUTHOR_EMAIL='harry@hogwarts.school.uk'
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=auto

# very handy to have your git branch and checkout status in your prompt:
export PS1='\[\e[1m\]\u@\h:\w\[\e[32;1m\]$(__git_ps1 "(%s)")\[\e[m\e[1m\]\$\[\e[m\] '

Track Mercurial transparently with git

To track a project hosted in a Mercurial repository, we can use the nifty hg-fast-export package. Install Mercurial and its fast export:

sudo apt-get install mercurial hg-fast-export

Use the Mercurial subcommand to clone your upstream Mercurial repository (Note the // in the path) into git.

git hg clone ''ssh://jack@beanstalk.net//var/lib/mercurial/magicbeans''

Updating is easy:

cd magicbeans
git hg fetch

Importing a CVS project from SourceForge into git

First, grab a clone of the remote CVS repository. The easiest way to do this with a SourceForge project, without having to actually use CVS and its pserver logins and whatnot, is to use rsync:

rsync -avz rsync://meta-extractor.cvs.sourceforge.net/cvsroot/meta-extractor cvs-clone

Now we're going to import the history of the relevant CVS module (in this case, "metadata-extractor") into a new git repository.

sudo apt-get install git-cvsimport
git cvsimport -C meta-extractor.git -p x -v -d $(pwd)/cvs-clone metadata-extractor

Now you can push your new git project to Github or somewhere:

cd meta-extractor.git
git remote add origin <your-new-git-repo>
git push --tags master

You're good to go!