Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use git svn? [closed]

Tags:

git

svn

Please provide tips for effectively using git with svn. What are your "best practices"?

like image 259
1800 INFORMATION Avatar asked Sep 30 '08 23:09

1800 INFORMATION


People also ask

What is the use of Git and SVN?

The difference between Git and SVN version control systems is that Git is a distributed version control system, whereas SVN is a centralized version control system. Git uses multiple repositories including a centralized repository and server, as well as some local repositories.

Can I use Git and SVN at the same time?

git works perfectly fine with a svn repository on the other side, why not benefit from that? Certainly possible, and a fair move towards your colleagues, not to push unfinished changes. however there is one huge danger hidden in there: you will tend to make very few commits to the companies repository.

What is git SVN command?

What is Git-SVN? The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.


2 Answers

When you create the clone, use --prefix=svn/. It creates nicer branch names.

Also, don't neglect the --trunk, --tags, and --branches arguments when doing clone or init.

Fetching is one of the more time-consuming steps, so set up a cron job to do git svn fetch in the background. This is safe because fetching doesn't affect any of your working branches.

( Background info on git svn fetch: This command is executed first whenever you do git svn rebase, so by doing this step ahead of time, your git svn rebase call will usually be faster. The fetch command downloads SVN commits and sticks them into special branches managed by git-svn. These branches are viewable by doing git branch -r, and if you did the above step, they start with "svn/". )

Make sure you know how to use git reflog. I've had a few occasions where git svn dcommit died (usually because I tried to check in something huge) and my commit seemed to be lost. In every case, the commit was easily found in the reflog.

like image 69
andy Avatar answered Sep 30 '22 05:09

andy


Here's some that I recently learned:

  1. always do git svn rebase before doing git svn dcommit
  2. when you are doing dcommit, do it from a temporary staging branch - if you (or git) mess up, it's much easier to recover by just deleting the branch and starting over

When svn dcommit dies halfway through a large commit and you seem to have lost all of your history, do this:

How To Recover:

First, open .git/logs/HEAD

Find the hash of the commit that's the head of your git repo. Hopefully you remember the commit message and can figure it out, but it should be pretty obvious

Back in your now f-ed up working-dir:

git reset --hard <hash from log>

This gets your working dir back to where it was before you did a git- svn dcommit. Then:

git-svn rebase git-svn dcommit

like image 23
1800 INFORMATION Avatar answered Sep 30 '22 07:09

1800 INFORMATION