Community
Participate
Working Groups
Build Identifier: 20110615-0604 If you delete a file or directory in a Git project, this un-commited change is not marked with a decoration in its parent directory. It's also not listed in a Tree Compare of the parent directory against the index. It is listed in the the Git Staging view, but the deletion can't be un-done from there. In fact there doesn't seem to be any egit operation that can undo an un-commited delete, except a hard reset of the repository as a whoIe. Reproducible: Always Steps to Reproduce: 1.Delete a file or directory 2. Notice that the parent directory of the deleted item does not highlight the un-commited change with any form of decoration. 3. Run a Compare With against he Index on the parent of the file or directory you deleted. 4. Note that the Git Tree Compare view makes no mention of the deleted item. 5. No operation in egit appears to be able to undo the deletion other than a full hard reset of repository. Command-line Git is needed in order to undo the delete of a single file or directory.
I found what seems to be a better workaround. In the "Git History" view, locate your current HEAD and right-click "Checkout". Or, in the "Git Repositories" view double click your current branch again. This is a better workaround because it will NOT discard your changes! It is still not optimal because it will restore ALL the files you deleted.
Note: the Synchronize feature could have been another option. However: - The Synchronize feature tends to be unusable on projects of a decent size. - Even on a small project, restoring files using the Synchronize feature seems to work at first but then triggers strange and scary exceptions.
Unfortunately not that simple. My "checkout" workaround above works only for *staged* deletions. Deleting *files* automatically stages the corresponding deletion, so far so good. Unfortunately, if you delete an *entire directory* from Eclipse then no deletion is staged at all! This is another, unrelated inconsistency/bug. Already filed elsewhere? So my "re-checkout" workaround above now becomes more cumbersome. But it still works: 1. In the "git staging" view, stage the deleted files you want to restore and UNstage the deleted files you want to keep deleted (totally counter-intuitive but do not forget all this is just a workaround). Staging/unstaging deletions can only be done by drag-and-drop in this window AFAICT. 2. Re-checkout your existing branch as described above, job done. Note: do not bother staging or unstaging *modified* files, nothing happens to them either way.
Never occurred to me that double-clicking the current branch entry in the 'Git Repositories' view, or invoking 'checkout' on the HEAD entry in the history, would have this side-effect. I just assumed these would be no-ops, like running 'git chekout <branch>' on the command line if you're already on <branch>. Somewhat unexpected behavior but a reasonable workaround.
In current build one can use the Staging View to restore deleted Files (see bug345002), Directories with deletions are marked.
Just tested release 1.1.0.201109151100-r and nothing has changed in respect to this bug. The Synchronize view now looks like it is working much better and faster generally speaking but, it does not address this specific deletion problem and still throws cryptic exceptions when trying to revert deletions. Did not try the latest builds (sorry Jan)
I tried this with today's nightly build (2011-11-25): > 1.Delete a file or directory > 2. Notice that the parent directory of the deleted item does not highlight the un-commited change with any form of decoration. - the parent directory has the * decorator for staged changes -> works as expected > 3. Run a Compare With against he Index on the parent of the file or directory you deleted. > 4. Note that the Git Tree Compare view makes no mention of the deleted item. - yeah, this doesn't show the staged deletion - tried "Team > Synchronize" -> correctly shows staged deletion > 5. No operation in egit appears to be able to undo the deletion other than a full hard reset of repository. Command-line Git is needed in order to undo the delete of a single file or directory. - I tried "Replace with > HEAD revision" on parent folder of resource which has been staged for deletion -> works as expected - also unstaging from staging view works, then do "Replace with file in Git index" from staging view entry -> works as expected - also unstaging from synchronize view works, then do "Overwrite" on the unstaged deletion -> works as expected So it seems the remaining problem is that the tree compare doesn't show staged deletions.
(In reply to comment #7) > I tried this with today's nightly build (2011-11-25): > - I tried "Replace with > HEAD revision" on parent folder of resource which has > been staged for deletion -> works as expected Did you try with a deleted directory or only with a deleted file? With yesterday's nightly build it works with a file but everything falls apart with a directory. See JGitInternalExceptions, failed asserts and stack traces in bug 345002
The latest nightly has 2 out of 3 problems fixed, see bug 345002
So the remaining problem is with the Git Tree Compare view not showing deleted folders? If so, there's bug 390886 for that which already has a proposed solution. We could close this one then.
(In reply to comment #10) > So the remaining problem is with the Git Tree Compare view not showing > deleted folders? I don't think so, see comment 17 in bug 345002#c17
(In reply to comment #11) > (In reply to comment #10) > > So the remaining problem is with the Git Tree Compare view not showing > > deleted folders? > > I don't think so, see comment 17 in bug 345002#c17 We should not keep more than one bug open for one problem, so I'm resolving this one. Please see bug 345002 for the remaining problem with Synchronize and bug 390886 for the Git Tree Compare view problem.