How to work with Git-svn when you need to use both Git and Subversion

[Update]

For more information, the reason I am trying to make clean Git at home is because my company would like to switch to Git, but the manager will not want to make changes because the developer does not have knowledge with Git in our own repository. So, what I'm trying to do, I'm trying to get everyone to use Pure Git, while someone can team up with Subversion at this point in the training. Thus, in any emergency, they can still use Subversion.

So, in front of everyone who is familiar with Git, I cannot transfer the repository to use pure Git. Thus, it will have both an update on Subversion and Git. (and the main repository right now is Subversion). So, I'm trying to make Git work smoothly while storing the synchronization repository using dcommit back to Subversion.

[Question]

I am in an organization using Subversion as a repository, so I will give it as my personal Git (and plan to use Subversion replacement with Git in the future)

Now I have a repository that uses Git and Subversion (Primary Source) . I have a problem with Git svn rebase when I have to use both Git and subversion.

My workflow is similar below

In the office

  • There is a Git-svn interface in the repository
  • I always pass Subversion code with Git svn dcommit from here.
  • I click on my remote git repository in bitbucket

To the begining

  • I am cloning a repository from Bitbucket
  • Working with and fixing Bitbucket

Now back to OFfice

  • git pull
  • git svn rebase
  • git svn dcommit
  • git click

In step 4. I have a problem that I have already rebuilt my branch

The problem is now here when I get home

When I get home, I cannot use 'git fetch' because the branch has already been reinstalled. So, I have to remove the branch using Git branch -D ..... and then Git checkout again.

So, I'm looking for a way that we can use the Git and Subversion repository at the same time, and work well with Git after performing an operation with Git svn rebase or Git svn dcommit.

Note. I will not prefer to use git-svn at home. Try moving forward to use only Git.

+7
source share
5 answers

Find a solution from Version Control with Git . Page 295.

Instead of using the local-master branch, you need to check the remote branch

git checkout remote/master (Detach HEAD) git merge --no-ff master (merge the local master) git svn dcommit git push origin (update to git Repository) 

This model is for one person who will merge back into the Subversion repository, while the other works with pure Git OR pure Subversion. Thus, Git Users can use Git without the problem of merging.

0
source

Well, your main problem here is that you can't really do git pull from home, the story is rewritten (in fact, it should work, but it will try to make an unnecessary merge).

The easiest way to overcome this problem is to use git pull --rebase . Thus, instead of merging the commits that you made at home with the tip of the remote branch, you reset all the commits made since the branch was created at the tip of the branch. Git will be smart enough to see that some commits are exactly the same names, and they will be automatically truncated during rebase.

+2
source

I assume the main cause of your problem is that git svn dcommit modifies the commit message to include SVN commit data. Since the message is included in the SHA1 commit, this change looks like git like a completely different message.

My solution for this would be to have one branch in your office repository in which you synchronize with SVN and another (purely git) branch to do your work. Whenever you want to exchange something with the SVN repo, you do merge in one direction or another.

In my case, I created another git repository designed exclusively for SVN sharing. I have a cron job that synchronizes this repo every 15 minutes with an SVN server. So I did not miss git svn rebase .

+1
source

You did not mention why you still keep svn. But my recommendation is to start with a clean git repository once and for all. And avoid unnecessary problems.

I believe Casey made the best answer for switching to git: How do I transfer the SVN repository with history to the new git repository?

Of course you need to backup and then start the process.

Another idea is that if the rebase problem is the problem, why not use a clean svn update and then commit the changes to git (git commit only), as if you wrote it yourself.

0
source

You should actually be able to git fetch , but instead of merging with git merge origin/branch you can use git rebase origin/branch . This should solve your problem.

If this does not help try git fetch , and then git checkout -f -B branch origin/branch , the last command will force the local branch to be overwritten from the remote branch.

0
source

All Articles