Difference between revisions of "Git-svn"

From PaparazziUAV
Jump to navigation Jump to search
(update git-svn info regarding the new git master repo)
(update and remove old info regarding cloning directly from svn)
Line 4: Line 4:
== Get the code ==
== Get the code ==
=== Clone a git mirror ===
=== Clone a git mirror ===
If you don't want to wait for ever when cloning the paparazzi3 subversion repository you can clone an already converted repository from [http://github.com/ github].
See the [[Git git page]] for that.
git clone -o github git://github.com/paparazzi/paparazzi3.git
 
If you list the remote branches with '''git branch -r''', you can see that you now have the subversion branches under origin/svn/*.
If you list the remote branches with '''git branch -r''', you can see that you now have the subversion branches under github/svn/*.
To update from this github mirror just run
To update from this github mirror just run
  git fetch
  git fetch
Line 28: Line 28:
  git pull
  git pull
or to get all the changes (including the ones from the svn branches) without merging the in run
or to get all the changes (including the ones from the svn branches) without merging the in run
  git fetch origin
  git fetch github


To update directly from svn run
To update directly from svn run
Line 35: Line 35:
Gitk is your friend if you want to visualise all branches and history:
Gitk is your friend if you want to visualise all branches and history:
  gitk --all
  gitk --all
=== Import directly from subversion repository ===
You can also directly import a subversion repository with
git svn clone URL
This will take a long time since git-svn will check out every revision in subversion.
To get the whole paparazzi3 repo including branches and tags and to get proper author information you need to add some options: The -s option refers to the standardlayout of the svn repository with trunk, branches and tags folders. The -A option specifies where to find the AUTORS file that is used to match svn users to the proper authors. Download the [http://svn.savannah.gnu.org/viewvc/*checkout*/paparazzi3/trunk/AUTHORS?root=paparazzi file] (the AUTORS the paparazi3 root dir has the correct format).
If you have write access to the subversion repository run:
git svn clone -s --prefix=svn/ -A path/to/authorsfile svn+ssh://<username>@svn.savannah.nongnu.org/paparazzi/paparazzi3
For read-only access run:
git svn clone -s --prefix=svn/ -A path/to/authorsfile svn://svn.savannah.nongnu.org/paparazzi/paparazzi3
After git checked out all revisions (can take a long time) permanently set the authors file:
cd paparazzi3
cp AUTHORS .git/svnauthorsfile
git config svn.authorsfile .git/svnauthorsfile
To update from svn just run
git svn rebase
== Get ignore information from svn ==
There is already a '''.gitignore''' file in the repository, so you won't need to do this.
If you still want to tell git to ignore files with the svn:ignore property:
git svn show-ignore >> .git/info/exclude
Or just add anything you want to ignore to the '''.gitignore''' file.

Revision as of 15:40, 22 October 2010

How to use git with the paparazzi subversion repository. See the Git - SVN crash course for an introduction into git for svn users or have a look the pretty comprehensive git-svn intro for how to use git together with svn. To get an understanding off the git internals the video Getting Git is excellent.

Get the code

Clone a git mirror

See the Git git page for that.

If you list the remote branches with git branch -r, you can see that you now have the subversion branches under github/svn/*. To update from this github mirror just run

git fetch

To be able to commit back to svn as well you will have to set this up. First make sure you have a proper svn-authors file (the AUTHORS file in the paparazi3 root dir has the correct format):

cp AUTHORS .git/svnauthorsfile

and tell git to use it

git config svn.authorsfile .git/svnauthorsfile

Since you only have the commits but not the SVN metadata you need to rebuild it. First make the all refs look just like they would look from a fresh import using git update-ref. To do this for all branches listed under github/svn/ you can run this small script:

git for-each-ref refs/remotes/github/svn/ | cut -d / -f 5- |
while read ref
do
git update-ref refs/remotes/svn/"$ref" github/svn/"$ref"
done

Tell git where to find the SVN repository and rebuild the index:

git svn init -s --prefix=svn/ svn+ssh://<username>@svn.savannah.nongnu.org/paparazzi/paparazzi3
git svn fetch

If you want to inspect your configuration work have a look at your .git/config file.

To get the changes from the master branch on the git mirror run

git pull

or to get all the changes (including the ones from the svn branches) without merging the in run

git fetch github

To update directly from svn run

git svn rebase

Gitk is your friend if you want to visualise all branches and history:

gitk --all