This page shows how to locally use git for private projects with only one developer, targeting a svn repository.

Getting started:

Installing git:

    $ sudo apt-get install git-core git-svn gitk
    $ git config --global user.name "My Name"
    $ git config --global user.email "my.name@somewhere.com"

Cloning the svn repository:

    $ mkdir ~/my_project; cd ~/my_project
    $ git svn clone https://url.com/svn/my_project .
    $ git repack -d

Committing:

Merge with svn repo (if no not-committed local changes): , discarding local changes:

    $ git svn rebase

Merge with svn repo, while temporarily stashing local changes:

    $ git stash
    $ git svn rebase
    $ git stash pop

See what's about to committed, changed, untracked:

    $ git status

See what's about to be committed:

    $ git diff --cached

Make a local commit:

    $ git commit <files>

Edit the last commit message, after committing:

    $ git commit --amend

Push all stacked commits back to svn repository:

    $ git svn dcommit

See a particular commit:

    $ git log --pretty=oneline       # list all commits
    $ git show <hash>                # show this commit

Branches:

List existing branches:

    $ git branch -a

Switch from one branch to an other:

    $ git checkout erwan
    $ git checkout master

Working with files:

Add a file to next commit:

    $ git add <file>

Other:

    $ git mv <from> <to> 

Restoring a file removed by mistake:

    $ rm trunk/t/test-order.t
    $ git checkout trunk/t/test-order.t

Diff history:

    $ git log -p

Discard local changes and go back to master:

    $ git checkout .
    $ git status