How can I do the equivalent of git rebase -i HEAD~2 in eGit?

我的梦境 提交于 2019-12-09 08:21:34

问题


I know how to rebase onto a specific branch or tag using eGit in Eclipse, but I haven't found a way to rebase onto a specific sha1 using eGit. I'd like to do this in order to squash commits before pushing to upstream (ie, doing git rebase -i HEAD~n where n is some number of commits ago where I want to rebase). Is this possible with eGit? If not, is there another Eclipse plugin I should be using that would provide this functionality?


回答1:


It is currently available in Eclipse Oxygen, it has it's own wizard for it.

  1. Get the branch you want in the History view
  2. Right-click the commit before the one you want to change
  3. Find Rebase interactive and click it
  4. The Rebase wizard will show up with the commits available to work upon

It works just like the console version, but on a GUI. Even if conflicts arise, it will help you through.




回答2:


EGit has rebase, but it does not yet have the interactive rebase you ask for.




回答3:


I've been successful squashing commits using steps from this post (cut and pasted here):

If I want to squash the last m commits on the current branch then I

  • select in history the first commit which I don't want to squash
  • right-click and say "Team->Reset->Soft"
  • right-click and say "Commit". This commit will contain all the changes of the last m commits together



回答4:


From the history view select the commit you want to rebase to, and create a branch called rebase-point or whatever. Voila, you can now rebase to that branch, and delete it later if you want. I generally prefer using a named branch for things like this anyway, because it minimizes the chance for mistakes on my part. Alternately, consider that origin/master is often the right rebase point if you're squashing commits for a push.




回答5:


You can also rebase from the Eclipse History view.

  • Select the repository from the Git Repositories view
  • Right-click and select Show In History
  • Select the commit you want to rebase the currently checked out branch on top of
  • Right-click and select the Rebase on Top of item
  • Note: You may need to select Show All Branches and Tags first from the History view toolbar to display the commit you are looking for in the table.


来源:https://stackoverflow.com/questions/7197152/how-can-i-do-the-equivalent-of-git-rebase-i-head2-in-egit

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