Changing the git branch on eclipse

一曲冷凌霜 提交于 2021-02-08 12:25:17

问题


This is the first time I do this. I imported a git project in eclipse. Then I used the shell to create another branch and checkout to the new branch.

Is refreshing the imported project in Eclipse enough to tell Eclipse that we are working on the new created branch?

thanks


回答1:


Right-click your project and select TeamBranch to create new branches or to switch between existing branches. You can also switch branches in the History view.




回答2:


Actually, I don't think you even need to refresh the project. That is, assuming you have 'eGit' installed and your projects are already configure as git projects (they should be, because in most cases, egit does that automatically).

Whenever you run git commands on the shell (outside eclipse) egit will automatically refresh projects for you and update their status when you switch back to Eclipse.

If you are not using egit then yes, you have to refresh the projects manually, but that is all you'd have to do since running the 'git checkout my-branch' command in the shell already changed the files on disk to be those from 'my-branch'.




回答3:


Actually when you are working with eclipse, eGit is a very cool tool integrated inside eclipse, which lets you do all git stuff, like

  1. git checkout to a new branch
  2. git create new branch
  3. git stash
  4. even view your unstaged changes(select files and avoid complexities caused by git add .)
  5. and finally commit.

Read here to know more. Eclipse Egit user guide So you get to do all version repository stuff at one place as you code.

So to answer your question, yes as you checkout a new branch even in a shell/command prompt your changes will be reflected in eclipse.



来源:https://stackoverflow.com/questions/24650027/changing-the-git-branch-on-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!