问题
I have Branch A and Branch B in the local branch folder.
Branch A is under working. Now I want to switch to B.
The window pops out:
Checkout Conflicts
The files shown below have uncommitted changes which would be lost by checking out 'master'.
Either commit the changes, stash the changes, or discard the changes by resetting the current branch.
project.properties.
There are 3 options:
Commit..
Stash...
Reset
No matter which option I choose, it does not work. For example, if I choose "Stash" option, it says:
"The repository does not contain any local changes to stash".
I suspect the egit records have some conflicts, so it cannot know how to do the next step.
The only way: To remove the local branches, and clone the remote repository to the local? This needs cost some time for downloading.
回答1:
IMO removing local branch is not required.
I suggest first to pull the remote changes to local Branch A.
Resolve any conflicts while pulling the changes if any. Refer this video
Add your changes to Git staging area just by dragging the the files from unstaged area to staged area refer pic below.
- Click on commit button, then push the changed to remote branch.
After doing this Branch A will be clean, then you can switch to Branch B just by double clicking on it or by right clicking on the repository node and selecting Switch to option in Git repository view.
Also I suggest to use the latest stable Egit plugin from here
回答2:
I had the same problem. EGit complaint about .class files which were not commited. I deleted the .class files and was able to switch to the desired branch without problems.
来源:https://stackoverflow.com/questions/22366266/switch-to-another-branch-in-egit-cannot-work