7

I am using git svn on my local machine to sync with a SVN repo.

Recently, someone in my team added some experimental stuff (he was trying to add some tags) to the SVN repo and deleted it later in the next commit. After this my git svn refuses to fetch. It just gets to a certain point and stays stuck there.

I would not want to fetch all that experimental stuff into my local machine anyway. So, I would like to ignore certain commits in the SVN repository. Is that possible with git svn?

Will
  • 24,082
  • 14
  • 97
  • 108
CSS
  • 71
  • 1
  • 2

4 Answers4

12

Say commit 666 is the one we need to skip. The trick is to make git fetch all of the commits other than 666. Thankfully, git-svn gives us the -r argument.

First, update to the commit immediately before the commit to be skipped:

git svn fetch -r BASE:665

Then, update everything after the bad commit to the Subversion tip:

git svn fetch -r 667:HEAD

That should give you a repository with everything except the commit you wish to skip. You can skip multiple revisions if necessary, just repeat the above commands for whatever range(s) of commits you do want to keep.

Skipping revisions can go awry if you skip file changes that will be affected by later revisions (e.g., you skip a file change or creation, and that file changes later in a revision you do fetch).

That said, I've just done it to skip a revision where someone had copied the entire Subversion repository into the tags/ directory, then deleted the obviously invalid tag. I used the above trick to skip the revision where the invalid tag was created (Git had been trying to download the entire repository), let it fetch the deletion (which it just ignored), and all was right with the world.

Will
  • 24,082
  • 14
  • 97
  • 108
me_and
  • 15,158
  • 7
  • 59
  • 96
  • 1
    Remember that at this point, you no longer need to specify the svn repo to fetch from. Use the command as given, not like how I was trying (adding the location of the svn repo to the end of the command)... – AndrewW Oct 05 '12 at 19:27
3

You could try to reset git-svn right before experimental commit and re-fetch.

git svn reset -r665
git svn fetch 

If the problem is still here and seems to be permanent (probably some files access modification) you could try another way.

First reset to last commit before evil one

git svn reset -r665

Then try to re-fetch completely ignoring all the files developer touched in evil commit

git svn fetch --ignore-paths='/path/to/problematic/files'

Then reset to the first normal commit after the commit that reverted the evil one.

git svn reset -r668

And refetch everything again.

git svn fetch

I suggest r666 is the evil commit and r667 is the one that reverted it.

the.malkolm
  • 2,391
  • 16
  • 16
  • This also usable when you wan to revert some changes. Just don't forget to follow cleanup procedure [(something like this)](http://www.ducea.com/2012/02/07/howto-completely-remove-a-file-from-git-history/) – ony Nov 14 '12 at 11:46
0

I had this same problem, finding I had to keep re-running the fetch. But then I found other, hung git svn fetch operations running in the background. Killing these seemed to fix the problem

-2

You could clone the repository again and use the depth parameter to specify the age...

git clone --depth 3 // Gets the last 3 revisions
Chris Pont
  • 789
  • 5
  • 14
  • or rather git svn clone --depth 3 for git svn – Chris Pont Sep 15 '11 at 12:20
  • Oh.. I have an existing repo which already has a lot of commits that I have cloned into my local machine.. I just want to ignore some revisions in the Main SVN branch while fetching.. – CSS Sep 15 '11 at 12:30