Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Remove/add file to some commit
Remove/add file to some commit [message #1795222] Tue, 18 September 2018 15:17 Go to next message
Dmitry Katsubo is currently offline Dmitry KatsuboFriend
Messages: 13
Registered: November 2010
Junior Member

Dear community,

I wonder how is it possible to remove the file from (or add a file to) previous commit?

I know that I can do it by doing Reset → Mixed in the history and then selecting "correct" list of files and doing commit again. This is so-so OK if the change is to be applied to last (top) commit in the history and the number of changed files is relatively small. But what if several commits before?

So I wonder how can I go it using interactive rebase... I have started interactive rebase, and then:

  • Commit viewer does not allow to remove files from the list of staged.
  • When I hit Amend button in Git staging view, staged files are not populated to Staged Changes, so I cannot remove them... I only can change the commit message.

I had to help Eclipse from command line:
git checkout "HEAD^1" FileToExcludeFromCommit.java

and then one can continue with "git commit --amend".

Adding a file would be
git add FileToAddToCommit.java

but again, cannot do it from Eclipse as Add to Index had disappeared from context menu.
Re: Remove/add file to some commit [message #1795244 is a reply to message #1795222] Wed, 19 September 2018 06:49 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 175
Registered: August 2016
Senior Member
Dmitry Katsubo wrote on Tue, 18 September 2018 15:17
I wonder how is it possible to remove the file from (or add a file to) previous commit?

In the project/package explorer, there's "<context menu>→Replace with...→ Previous revision".

Then add the replaced file to the index.

About being able to do this in the git staging view, there's bug 490126.

Dmitry Katsubo wrote on Tue, 18 September 2018 15:17
But what if several commits before?

There are also "Branch, Tag, or Reference..." or "Commit..." in that context menu.

Dmitry Katsubo wrote on Tue, 18 September 2018 15:17

but again, cannot do it from Eclipse as Add to Index had disappeared from context menu.

Probably because Eclipse hasn't picked up the change done outside of Eclipse yet. Try refreshing the file in the project/package explorer first.
Re: Remove/add file to some commit [message #1795345 is a reply to message #1795244] Thu, 20 September 2018 15:41 Go to previous message
Dmitry Katsubo is currently offline Dmitry KatsuboFriend
Messages: 13
Registered: November 2010
Junior Member

Quote:
In the project/package explorer, there's "<context menu>→Replace with...→ Previous revision".

I think you miss something. Once you have started interactive rebase, there is no Replace with...→ Previous revision
Quote:
There are also "Branch, Tag, or Reference..." or "Commit..." in that context menu.

I don't see those items. Again, when not in interactive rebase, they are present.

So the question how to modify commit deeper than HEAD is still an open question.

As for interactive rebase, how can I do the following. Suppose we have commits:
A1(HEAD)->A2->A3->...

Now I want the group of files to be removed from the commit A3 and added to commit A2. Or (if other commits namely A2, A1 are just replayed / picked) left as unstaged changes on HEAD.

[Updated on: Thu, 20 September 2018 15:43]

Report message to a moderator

Previous Topic:How to avoid mesage during commit messsages??
Next Topic:Problems locating multiple tags that reference the same commit
Goto Forum:
  


Current Time: Sat Dec 14 07:08:49 GMT 2019

Powered by FUDForum. Page generated in 0.02279 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top