Version 2 (modified by coke, 6 years ago)

--

First, we need to fetch a copy of the repository.

git svn clone -s -r 34140 https://svn.perl.org/parrot # choose some recent-ish commit

-s is for --stdlayout which presumes the svn recommended layout for tags, trunk, and branches.

-r is for the revision to start taking history from. If you want to include all of the history, just leave that option off, but it will take a very long time, and you really don't need all of it. You could also ask around for a tarball of the repo with history if you don't want to use the bandwidth and time.

This will create a directory in the current directory named 'parrot'. If you want to specify the directory to create, pass one more argument.

Now, start working on patches. The simplest way to work, without local branches, is:

    hack; hack; hack; hack

    git diff # look at differences since the last commit

If you want to commit all of these changes, run:

    git commit -a

and enter your commit message. This creates a local commit only. It hasn't been pushed to the SVN server yet. If you only want to add changes from some files but not others, run:

    git add file1 file2 file3 ...
    git add -i file4 # if you only want to add some diff hunks and not others
    git commit

and enter your commit message. After this, 'git diff' will still show the uncommitted changes. While you're adding changes to be committed, you can run 'git diff --cached' to see what's going to go in the next commit.

After you've made however many commits, you can push up to the svn server with:

    git svn dcommit

That will also bring your local tree up to date. To bring your tree up to date in general, run:

    git svn rebase

This will update your local checkout and then re-apply your local un-submitted commits on top of the new trunk.

Questions

We've heard a lot about how git will ease the pain of working in branches; can you provide an example, showing a branch that all committers can collaborate on, that can be rebased against trunk as needed, and then merged back to trunk?

Attachments