SVN切换到比工作副本更旧的分支

发布于 2024-11-17 22:53:07 字数 920 浏览 4 评论 0原文

我对主干的工作副本进行了更改。然后,我想切换到另一个分支,以便我可以致力于它。我做到了,现在我的项目一团糟。我切换到的分支位于主干后面,并且缺少我修改过的文件。我很沮丧,又回到了后备箱。

现在,我在几个地方出现树冲突,显示“本地编辑,切换时传入删除”。由于冲突,我无法提交这些内容。我能看到的唯一选择是恢复我的本地更改,或者基本上重新签出整个项目并丢失所有更改。

另一个问题 - 我恢复(并删除)了具有此类树冲突的文件夹之一。所以现在,我可以看到该文件夹​​存在于存储库中,但它已从我的本地项目中消失,并且更新不会将其带入我的工作副本中。这里发生了什么事? 1. 它存在于存储库中,2. 它不存在于我的工作副本中,因为我刚刚删除了它,3. 更新不会将其带入我的工作副本中。这是为什么呢?

为什么这么难?我有本地更改,我想提交它们。我不明白为什么我切换到另一个分支并再次返回很重要。如果该文件在我切换到的分支上不存在,为什么我不能将我的文件提交到该分支以便它存在?

这是 Eclipse 为我提供的其中一个树冲突的信息,这是对我切换到的分支上不存在的文件的本地更改。我假设它想在我切换时删除该文件,因为它不在分支中。那么我现在该如何解决这个问题呢?我真正想做的是将其添加到分支并提交我的更改,但我不能,因为现在存在冲突!

Resolve Tree Conflict on my_jsp.jsp
Conflict Description:
local edit, incoming delete upon switch
Source left: (file) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@349
Source right: (none) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@353

它给我的唯一选择就是恢复、删除或比较,所有这些都是不可接受的。我有很多本地更改!

I made changes to my working copy of the trunk. Then, I wanted to switch to a different branch so that I could commit to it. I did, and now my project is a mess. The branch I switched to was behind the trunk and was missing files to which I made modifications. Frustrated, I switched back to the trunk.

Now I have tree conflicts in several places that say "local edit, incoming delete upon switch." I can't commit these because of the conflict. The only option I can see is to revert my local changes, or basically re-checkout the entire project and lose all my changes.

Another problem - I reverted (and deleted) one of the folders that had such a tree conflict. So now, I can see that folder exists on the repository, but it's gone from my local project and updating does NOT bring it into my working copy. What's happening here? 1. It exists on the repo, 2. it does NOT exist in my working copy because I just deleted it, and 3. updating does NOT bring it into my working copy. Why is this?

Why is this so hard? I have local changes, and I want to commit them. I don't see why it matters that I switched to another branch and back again. If the file doesn't exist on the branch I switch to, why can't I just commit my file to the branch so that it does?

Here's what eclipse is giving me for one of the tree conflicts, which was a local change to a file that didn't exist on the branch I switched to. I'm assuming it wanted to delete the file when I switched because it wasn't in the branch. So how do I fix this now? Really what I want to do is add it to the branch and commit my changes, but I can't because there's a conflict now!

Resolve Tree Conflict on my_jsp.jsp
Conflict Description:
local edit, incoming delete upon switch
Source left: (file) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@349
Source right: (none) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@353

The only options it gives me is to revert, remove or compare, all of which are unacceptable. I have lots of local changes!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城追梦 2024-11-24 22:53:07

对于您的第一个问题:

您可以做的一件事是对当前更改进行补丁,然后恢复到主干并应用您的补丁。如果你运行的是 Linux,命令看起来会像这样

svn diff > ~/patch.diff
svn switch svn://path/to/trunk
patch -p0 < ~/patch.diff

,这应该会让你或多或少回到原来的状态(希望如此)。如果您运行的不是 Linux,Eclipse 或 SVNTortoise 中应该有类似的命令。当您想要转到新分支时,为了安全起见,请再次进行比较。如果确实远远落后,您可能必须手动进行更改,或者确保首先将分支与主干合并(如果可以选择)。

对于你的第二个问题:

我想我见过类似的东西,但我不记得问题是什么。您是否尝试过 svn up 来更新丢失的文件?

For your first problem:

One thing you could do is make a patch of your current changes, then revert back to the trunk and apply your patch. If you're running linux the commands would look something like

svn diff > ~/patch.diff
svn switch svn://path/to/trunk
patch -p0 < ~/patch.diff

That should get you back to more or less where you were (hopefully). If you're not running linux, there should be similar commands in Eclipse or SVNTortoise. When you want to go to the new branch, make a diff again just to be safe. You might have to make the changes manually if it's really far behind, or make sure you merge the branch with trunk first (if that's an option).

For your second problem:

I think I've seen something similar but I don't recall what the issue was. Have you tried svn up <file_name> to just update the missing file?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文