CSS
CSS

Reputation: 71

With "git svn", Can I Ignore Specific Git Commits While Fetching?

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?

Upvotes: 7

Views: 3674

Answers (4)

me_and
me_and

Reputation: 15654

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.

Upvotes: 12

user1315637
user1315637

Reputation:

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

Upvotes: 0

the.malkolm
the.malkolm

Reputation: 2421

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.

Upvotes: 3

Chris Pont
Chris Pont

Reputation: 791

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

git clone --depth 3 // Gets the last 3 revisions

Upvotes: -2

Related Questions