我正在和一个朋友一起做一个项目,我想返回到我们代码的旧版本,并将其设置为当前版本。我该怎么做?
我在vs08上使用“anksvn”。
我的电脑上有我想要的版本,但提交失败;我得到的信息是 "提交失败,文件或目录已过期。"
我的电脑上也有subversion客户端。
我正在和一个朋友一起做一个项目,我想返回到我们代码的旧版本,并将其设置为当前版本。我该怎么做?
我在vs08上使用“anksvn”。
我的电脑上有我想要的版本,但提交失败;我得到的信息是 "提交失败,文件或目录已过期。"
我的电脑上也有subversion客户端。
当前回答
同步到旧版本并提交。这应该能奏效。
这里还解释了撤消更改。
其他回答
您只能在颠覆历史记录的头部提交新的更改。
你不能直接用你电脑上的好拷贝做任何事情的原因是,它的.svn文件夹知道它是过去的代码,所以在提交之前需要更新。
找到好的修订号并恢复
Find the revision number of the old copy you want. Get your current revision with: svn info --show-item revision # or svn log Or to check older versions of your project, use: svn update -r <earlier_revision_number> until you find the right revision number. Note down the good revision number (assuming 123 for examples below). Update to the latest revision: svn update Undo all the changes between the revision you want and the latest version: svn merge -r HEAD:123 . svn commit -m "Reverted to revision 123" (the same as Jon Skeet's answer above.)
如果你找不到修订号
如果你找不到旧的副本,你只想提交当前在你的电脑上的文件:
Make a copy of your good version (but without any .svn folders): cd .. rsync -ai --exclude=.svn project/ project-good/ Now make sure you have the latest version: cd project svn update # or make a fresh checkout svn checkout <url> Copy your good version over the top of the working copy. This command will copy, and also delete any files from the working tree that aren't in your good copy, but it won't affect the existing .svn folders. cd .. rsync -ai --exclude=.svn --delete project-good/ project/ If you don't have rsync, you can use cp -a but you will also need to delete any unwanted files manually. You should be able to commit what you have now. cd project svn commit -m "Reverted to good copy"
基本上你需要“向后合并”——将当前版本和以前版本之间的差异应用到当前版本(因此你最终会得到一个看起来像旧版本的工作副本),然后再次提交。例如,从150版(目前)回到140版:
svn update
svn merge -r 150:140 .
svn commit -m "Rolled back to r140"
Subversion红皮书对此有一个很好的章节。
有点老派
svn diff -r 150:140 > ../r140.patch
patch -p0 < ../r140.patch
然后是通常的
svn diff
svn commit
就用这条线
svn update -r yourOldRevesion
您可以使用以下命令了解您的当前版本:
svn的信息
下面的方法对我很有效。
我有很多本地更改,需要在本地副本中丢弃这些更改,并在SVN中签出最后的稳定版本。
检查所有文件的状态,包括被忽略的文件。 Grep所有行以获取新添加和忽略的文件。 将这些替换为//。 rm -rf所有的直线。 SVN状态——no-ignore | grep '^[?I]' | sed "s/^[?I] //" | xargs -I{} rm -rf "{}"