Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-svn

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?

like image 733
CSS Avatar asked Sep 15 '11 12:09

CSS


People also ask

What does Git SVN fetch do?

This retrieves all the changes from the SVN repository and applies them on top of your local commits in your current branch. This works like, you know, a rebase between two branches :) You can also use git svn fetch to retrieve the changes from the SVN repository but without applying them to your local branch.

Can I use Git and SVN at the same time?

No interaction between them. Just ignore the . git folder for SVN and the . svn folder for Git and you should be fine.

Why do people prefer Git over SVN?

Many people prefer Git for version control for a few reasons: It's faster to commit. Because you commit to the central repository more often in SVN, network traffic slows everyone down. Whereas with Git, you're working mostly on your local repository and only committing to the central repository every so often.


1 Answers

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.

like image 130
me_and Avatar answered Oct 05 '22 13:10

me_and