Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

git svn - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...