本文介绍了使用“git svn”,我可以在提取时忽略特定的Git提交吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地机器上使用 git svn 与SVN回购同步。



最近,有人在我的团队中添加了一些实验性的东西(他试图添加一些标签)到SVN仓库中,并在稍后的提交中将其删除。在这之后,我的git svn拒绝提取。它只是到了一定程度,并停留在那里。



无论如何,我不想将所有这些实验性的东西拿到我的本地机器中。所以,我想在SVN存储库中忽略某些提交。可以用 git svn

解决方案

commit 666 是我们需要跳过的一个。诀窍是使 git 获取 。谢天谢地,git-svn给了我们 -r 参数。

首先,在提交之前立即更新提交被跳过:

  git svn fetch -r BASE:665 

然后,在Subversion提示的不良提交之后更新所有内容:

  git svn fetch -r 667:HEAD 

这应该会为您提供除commit你想跳过。如果需要,您可以跳过多个修订版,只需重复上述命令就可以保留任何提交范围。

文件更改将受到以后版本的影响(例如,您跳过文件更改或创建,并且该文件稍后会在您获取的版本中进行更改)。



,我刚刚做了一个修改,其中有人将整个Subversion版本库复制到标签/ 目录中,然后删除了明显无效的标签。我使用上述技巧跳过创建无效标签的修订(Git试图下载整个存储库),让它获取删除(它只是被忽略),并且全世界都是正确的。


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?

解决方案

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.

这篇关于使用“git svn”,我可以在提取时忽略特定的Git提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:45