From BlenderWiki

Jump to: navigation, search

It is possible to use git and git svn to get the Blender source.

Motivation

  • See here: http://whygitisbetterthanx.com/
  • Branching and committing is local only. (Though, when you commit these to SVN, of course this is lost.)
  • Git is much faster with the logs and diffs.
  • Git will not let you lose changes by accident, by clobbering with merges.
  • Interesting git tools like:
    • git bisect
    • git stash Most useful if you have outstanding modifications but want to update from the central server. For local projects, using a branch is better.
      • git stash Save the modifications with a decidedly unhelpful description (good for very temporary stashes).
      • git stash save some useful descriptionSimilar, but more suited to stashes that will hang around for a while (eg, you're uncertain about the direction your code is heading).
      • git stash list Display a list of existing stashes.
      • git stash pop Apply and if successful, delete the top-most stash (stash@{0}).
      • git stash show -u <stash> Show the specified stash as a unified diff.
      • git stash --help Much more help.
    • git checkout -b branchname Create and jump to a branch.
    • git checkout branchname (Note: no -b) Jump to an already existing branch.

Steps

First you need to install git and git-svn.

Setting up the SVN mirror for blender

Note: Currently there is a problem with the subversion access, you have to append

ssl-trust-default-ca = no

to the file $HOME/.subversion/servers if you get SSL certificate errors

Two methods are possible here:

Import svn from scratch

git svn clone https://svn.blender.org/svnroot/bf-blender/trunk/ blender-svn
  • Note: This will take more or less 10 hours (yes, hours). It is slow since the process requires checking out each SVN revision starting at r1, then committing it to the git repo.
  • Also note: You can relocate this tree without consequence. A .git/ dir is in the top directory, and will work wherever you put the tree.
  • Use git svn rebase to fetch all new revisions from svn and update your working copy (your checkout) to the latest revision

Import the gitorious mirror then takeover with git svn

git clone git://gitorious.org/blenderprojects/blender.git blender-svn
cd blender-svn
git svn init --ignore-paths '^lib' https://svn.blender.org/svnroot/bf-blender/trunk
git config svn-remote.svn.fetch :refs/remotes/origin/master
git svn rebase
  • The git clone from gitorious takes approx 10 minutes with a 600kB/s connection. The next three operations take less than 20 seconds total (unless the git mirror is lagging behind svn)
  • You can use git svn rebase as in the "from scratch" repository
  • You can also use git pull --rebase then git svn rebase to fetch the new revisions from gitorious and let git svn acknowledge/validate these. This can be much faster if your local history is lagging more than 50 revisions behind the gitorious mirror.
  • The gitorious mirror is maintained by jesterKing and is updated automatically every 5 minutes

You can use the git mirror standalone by only using the first git clone above, but

  • You rely on an unofficial mirror (jesterKing's automated translation is not guaranteed to be 24/7 no downtimes, I never had problems but still)
  • You lose the ability to commit to svn from your git repository
  • You lose the benefit of git svn commands like git svn find-rev which finds the SHA-1 of a commit corresponding to a given svn revision number. It is doable with git log --grep but less easy, prone to errors and slower
  • The other operations are really fast anyway compared to the git clone and don't use much space

Getting addons

Addons are in the bf-extensions SVN repository. I recommend to import it at the top level of the blender repo (that is, in blender-svn). Again you can use either:

git svn clone https://svn.blender.org/svnroot/bf-extensions extensions

or:

git clone git://gitorious.org/blenderprojects/extensions.git
cd extensions
git svn init https://svn.blender.org/svnroot/bf-extensions
git config svn-remote.svn.fetch :refs/remotes/origin/master
git svn rebase

You then can setup symlinks so that the build system finds the addons (assuming you are back in blender-svn):

ln -s ../../../extensions/trunk/py/scripts/addons blender/release/scripts/addons
ln -s ../../../extensions/contrib/py/scripts/addons blender/release/scripts/addons_contrib

Some git configuration for more comfort

In order not to accidently commit the extensions subtree or any of the symlinks you can make Git ignore them by putting the following in blender-svn/.git/info/exclude (you can replace that file, by default it only contains explanatory comments):

/extensions/
/blender/release/scripts/addons
/blender/release/scripts/addons_contrib

You probably also want to append the following lines:

/install/
/build/
*.pyc

blender-svn/.gitignore would also work, but if you go this route, be sure and append .gitignore so it ignores itself. Otherwise, it will appear as an untracked file, and runs the risk of accidentally being committed (which we don't want here to avoid polluting the SVN repo by mistake).

Further Info