|
|
|
|
|
|
Re: How do I squash commits? [message #1032824 is a reply to message #1032251] |
Wed, 03 April 2013 13:30 |
Stefan Lay Messages: 342 Registered: July 2009 |
Senior Member |
|
|
Thorsten Willard wrote on Tue, 02 April 2013 15:23Quote:Christian Halstrick: right-click and say "Team->Reset->Soft"
When right clicking on a commit listed in history there is no "Team->Reset->Soft".
I think you meant say right click on the top most folder of the project in Package Explorer then: Team->Reset
But this says: "Select a branch to reset the current branch to"
Which is not correct.
If you right click on the commit you want to keep in the History view then hover over the "Reset" choice, 3 other sub-choices appear: Soft, Mixed and Hard.
You should use the History View, Reset -> Soft (apparently there is no team menu), only here you can reset to an arbitrary commit.
Quote:
Then you said:
Quote:"right-click and say "Commit". This commit will contain all the changes of the last m commits together"
I assume you mean right-click on the same commit as you did when you did a "Soft reset" but there is no "Commit" choice when right-clicking on it.
Do you mean to right-click on the topmost folder in Project Explorer and go to team->Commit ?
Then you just get: "No changed items were selected, do you wish to amend the last commit?"
After a soft reset to another commit, in 99,999% of the cases you will have changes in your working tree and you can do a normal commit, either from Team->Commit in the Package/Project Explorer (can be done on any entry, not only the topmost folder), the tool bar or the staging view
|
|
|
|
Re: How do I squash commits? [message #1033550 is a reply to message #1032913] |
Thu, 04 April 2013 11:04 |
Stefan Lay Messages: 342 Registered: July 2009 |
Senior Member |
|
|
Quote:But how does this squash? I don't understand. After I select the commit I want to keep and do a soft reset on it, then what? Select the next to the last commit and try to commit over it? Then Eclipse just says: "No changed items were selected. Do you wish to amend the last commit?"
The idea is the following: You have commits
c <- branch <- HEAD
|
b
|
a
You want to squash c and b.
1. Do a soft reset to a (you want to keep a)
c
|
b
|
a <- branch <- HEAD
Now you have the changes of b and c in the working tree.
2. Commit
c
|
b d <- branch <- HEAD
|/
a
Now you have created a new commit d which squashes b and c.
(Note: You could also have 1. reset to b and 2. do a commit --amend. By that you could reuse the commit message of b)
Quote:tool bar: I don't see a commit button on the toolbar. In which view?
You can switch it on. See here: http://wiki.eclipse.org/EGit/User_Guide#Git_Workbench_Toolbar_and_Git_Workbench_Menu
Quote:staging view: I don't have anything staged.
After reset you have a dirty working tree. In the staging view you have to stage the changes before you can commit them.
[Updated on: Thu, 04 April 2013 11:05] Report message to a moderator
|
|
|
Re: How do I squash commits? [message #1034720 is a reply to message #1033550] |
Fri, 05 April 2013 20:25 |
R Shapiro Messages: 386 Registered: June 2011 |
Senior Member |
|
|
After a soft reset the previously committed changes will still be indexed, not dirty in the working tree. That's exactly the difference between soft and mixed. So a soft reset followed immediately by a commit squashes all the intervening commits into one. Very easy (assuming you don't have unrelated changes in the working tree)
It might help to think of it as follows. The standard working pattern in Git is edit, add, commit. The three usual kinds of reset undo these to different extents. A soft reset undoes the commits, a mixed reset undoes the commits and the adds, a hard reset undoes the commits, the adds and the edits.
Note that in addition to simple squashing, a soft or mixed reset combined with the EGit index editor is a nice way to restructure a set of commits more generally. For instance you might realize that change X really belongs in commit C1 rather than commit C2, or that commit C3 should really be split into two commits. All easily done in EGit.
[Updated on: Fri, 05 April 2013 20:50] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03926 seconds