0

I have a project in an SVN source, which will have to be migrated to a Git repository. What I'd like to do is committing all changes to Git repo from now on, while still fetching eventual changes from SVN, until it's dismissed.

At the moment, I created the Git Repo, used git svn to clone it from the original SVN and pushed everything into Git. Issue is, if I do a Pull, I'm fetching the modifications from Git, which is not what I want.

In practice, I'm trying to "fork" the SVN repository into Git and tracking SVN changes. Is it possible to do that?

Thanks in advance for the answers.

Diego
  • 7,312
  • 5
  • 31
  • 38
  • Why, oh why would you want to do this? What's the reason for the unnecessary complexity? – duffymo Aug 22 '12 at 11:48
  • 1
    Simply because we'll be moving to Git, but there are 3rd parties involved who won't do it yet. – Diego Aug 22 '12 at 11:51

3 Answers3

1

Yes you can do that, in your git repo, the master branch is tracking git-svn so when you run git svn rebase it updates master with the content in SVN. In this same repository you can have another branch which merges regularly master but contains modifications that will not be sent back to SVN.

While migrating from svn to git we have the same workflow than described in this answer.

Community
  • 1
  • 1
jolivier
  • 7,380
  • 3
  • 29
  • 47
  • So `git svn rebase` is the equivalente of an `svn update`? And will commits all end up in Git, not in SVN? Sorry if I'm asking something basic, I'm very new to Git and I still don't know it well. – Diego Aug 22 '12 at 12:13
  • its the equivalent yes, and all commits in the `master` branch (or the one tracking `git-svn`) will end up in svn when you run `git svn dcommit`. The reality is a little bit more complex, you will need to read detailed articles like http://andy.delcambre.com/2008/03/04/git-svn-workflow.html if you are using it in a development team, its quite critical. – jolivier Aug 22 '12 at 12:20
  • Ok. I don't actually want to commit anything to SVN anymore, only 3rd parties will do it using their SVN tools. Therefore, if I understood it correctly, I could go on with `git svn rebase` to get their updates, then `git commit` and `git push` to send them to my Git repo. Would that be correct? – Diego Aug 22 '12 at 12:35
  • `git svn rebase` will copy the SVN commits to your `master` branch, then you can `push` this `master` branch to your git repository (there is no need to commit, `git svn rebase` will create a git commit per svn commit) – jolivier Aug 22 '12 at 12:38
  • Ok, perfect. That's exactly what I wanted to achieve. – Diego Aug 22 '12 at 12:39
  • @Diego `git-svn-rebase` will modify the history of `master`. You won't be able to push without `-f`. You need a separate `svn` branch, which represents upstream `svn` changes, and then continually merge that into `master` – alternative Aug 22 '12 at 17:46
  • @alternative That's ok to me. The SVN Team and I will be working on different and independent parts of the project, there will be no clashes anyway. What I could probably do is branching my part while I keep "rebasing" with SVN, then merge my changes into the master and push. That should work. – Diego Aug 22 '12 at 18:02
1

Currently, there is git svn rebase, as mentioned, which will allow you to get upstream changes from svn.

Note that there is currently a GSoC project for adding svn remotes. Its on its fifth version of the patch series at the moment.

git svn rebase will cause you extreme problems, though, for example if you push to a public repository and git svn rebase. For this reason you cannot push changes not in svn to the main git repository.

alternative
  • 12,703
  • 5
  • 41
  • 41
1

If you want to use Git while letting 3rd parties to use your SVN repository, you can simply use any transparent Git<->SVN gateway, like SubGit. You will continue with Git forgetting about SVN, and SVN-users will never know you have a Git interface.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • Thanks Dmitry, but we already have an infrastructure in place. However, I'll surely take note of your suggestion, it may come handy in the future. – Diego Aug 22 '12 at 13:54