1

it is my first attempt to make git-svn project. I have Debian server with direct access.

Info: - local SVN is one branch and i won't be doing any local or remote commits

What i want to archive:

  1. Create true GIT local repository. That's easy :-]

  2. Create SVN local copy(or git-svn repo ? i don't know witch will be better in this case) of http://miranda.googlecode.com/svn/trunk/ (one branch) and then automatically get all changes via some script that detect remote changes and run "svn update" after.

  3. Somehow get all "changes" one by one (files and commit messages) from local SVN repo to local GIT repo and a branch named "Miranda-svn". So when you look and the commits/log for this specific branch, you will see the same messages as http://code.google.com/p/miranda/source/list has.

  4. Push "Miranda-svn" branch to the remote github.com account, project name "Test", branch name "Miranda-svn"

  5. Merge branch "Miranda-svn" with "master"

Can somebody help me ? Is there some example of such setup ?

ALIENQuake
  • 520
  • 3
  • 12
  • 28

1 Answers1

3

This is pretty straightforward with Git.

First "clone" the remote repository with git svn

git svn init --trunk=trunk http://miranda.googlecode.com/svn miranda
cd miranda
git svn fetch
git checkout -b Miranda-svn remotes/trunk 

Note: You may wish to limit the number of revisions fetched by using the -r start:end switch

Then add a new remote for github

git remote add origin git@github.com:myuser/test.git

Finally push changes to the github remote

git push origin Miranda-svn

To update Git branch with contents from SVN:

git checkout Miranda-svn # Just to be sure that we are on the correct branch
git svn rebase
git push origin Miranda-svn

Merge SVN changes to another Git branch:

git checkout master # Or whatever branch you want
git merge --no-ff Miranda-svn

NB! As SVN has linear history and the "svn" branch will be rebased on every "pull" you do not want to commit anything into Miranda-svn branch with this setup.

anttix
  • 7,709
  • 1
  • 24
  • 25
  • But how to get further updates/commits after "git svn clone http://miranda.googlecode.com/svn/trunk miranda" ? It looks to me as one-time operation and i want an constant update from svn repo to git/Test/Miranda-svn branch. – ALIENQuake Jul 29 '12 at 22:11
  • git svn dcommit and git svn rebase – anttix Jul 29 '12 at 22:13
  • Updated the answer to rename "master" branch to Miranda-svn as requested – anttix Jul 29 '12 at 22:23
  • git svn dcommit - i don't wnant to do any commits to the local/remote SVN repo. git svn rebase - does it will have all commits messages ? Or it is necessary to run this command every tme when remote SVN repo will get new commits ? – ALIENQuake Jul 29 '12 at 22:24
  • Yes you need to run the command every time you want to get the changes from SVN repo. The number of new revisions does not matter, git-svn will fetch all new revisions it will find. Just like you do svn update when using SVN. You also have to bear in mind that SVN has linear history, therefore rebasing SVN branch is the only option to maintain it. As long as you do not want to commit anything from Git to SVN, you should be fine though. – anttix Jul 29 '12 at 22:28
  • Thx ! I will definitely try this ! – ALIENQuake Jul 29 '12 at 22:36
  • I do every step and it was working fine but now i wnat to get all SVN changes from remote repo. I run git svn rebase and i get: Current branch miranda-svn is up to date – ALIENQuake Jul 30 '12 at 15:15
  • Ofc remote SVN repo was changed, there are atlast 3 new commits. What i can do to get those new changes/commits ? – ALIENQuake Jul 30 '12 at 15:31
  • if git svn rebase is not pulling, try git svn fetch first – anttix Jul 30 '12 at 15:55
  • root@:~/git/miranda-ng-svn# git svn fetch ... r1277 = 74110b566f89a13ce278b5f0580696520ec64df5 (refs/remotes/trunk) root@:~/git/miranda-ng-svn# git svn rebase First, rewinding head to replay your work on top of it... Fast-forwarded miranda-ng-svn to refs/remotes/trunk. works ! but: root@ip-10-55-30-172:~/git/miranda-ng-svn# git push origin miranda-ng-svn fatal: 'origin' does not appear to be a git repository fatal: The remote end hung up unexpectedly :( – ALIENQuake Jul 30 '12 at 16:11
  • Means you added a wrong GIT repository url as origin. Double check the URL from GitHub – anttix Jul 30 '12 at 16:35
  • Type git branch to double check the branch name and make sure there are no typos in your git push command. It seems to me that miranda-in-svn != miranda-ng-svn – anttix Jul 30 '12 at 16:38
  • Yes, it was stupid typos. I have one more question: https://github.com/ALIENQuake/Miranda-NG/commits/miranda-ng-svn - as you can see there is "Watcher"(witch have email) and "watcher" (with don't have email because there is no avatar and avatar is based on gravatar account email). So with every "fetch"/rebase command i should add --authors-file=../miranda-ng-svn-authors.txt ? – ALIENQuake Jul 30 '12 at 16:49
  • It's probably better to pass it to init command and make sure it's correct in config http://stackoverflow.com/questions/5464343/relative-paths-for-git-svn-svn-authors-file If it is correct, then it's likely that you need another entry in the authors file to take care of the different usernames / e-mails used by mr watcher – anttix Jul 30 '12 at 19:34