开发者

Egit: Checking out two different versions

What is the best way to checkout two different versions of a project in Eclipse Egit and have them show up in seperate directories?

My situation is as follows. I was working on a project and made some good changes and some bad changes (State A). I want to check out a previous working version of my project (State B) and copy and paste some of the good changes from State A into State B. Every time I try to check 开发者_如何转开发anything out it just replaces the files shown in the package explorer.


That's because one Git repository has one working directory, and the working directory reflects all branch changes etc. So if you want two versions, you need two repositories (just clone the one). Since you cannot import two projects with the same name in one Eclipse workspace, you have to rename one project after the checkout and before project importing.

But you could also use the Compare mode. Select the project, choose Compare with -> Branch, Tag or Reference and select the other branch, with which you want to compare. Then you can just add the contents from the other branch to the current files.


What you're asking for is not very git-ish, but here's how you'd do it.

You'd take your existing repository and you'd clone it to a new repo. In that new repo, you'd check out your "to" version (either by branch or tag or commit ID) and in the old one you'd check out the "from" version. Then you'd point Eclipse at the two directories to create projects from them.

Then you've got two projects in Eclipse, each containing a working directory that is the different versions, and you can manually move code from "from" to "to". Once your "to" project is the way you want it, commit that, delete the "from" repo and project, and Bob's your uncle.

The git-ish way of doing this is to use git bisect to find the commit that contained the bad change, and then revert that commit either in whole or in part.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜