Eclipse Git plugin - remove file from repo without deleting local - eclipse

Using the Egit plugin, is it possible to permanently remove a file from source control without deleting the local copy?
I.e., is there a GUI action equivalent to running "git rm --cached"?
(Edited to simplify question)

I have found the answer. Team->Untrack is indeed the equivalent of "rm --cached". However there is a known bug which produces weird behaviour when you untrack and then try to commit.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=363405

Team -> Advanced -> Untrack
did the job (git rm --cached) for me.

I had the same problem, after not initially including directories and files in .ignore. I also tried "Untrack" and "Remove from index" possibility, non of which helped(due to the still unresolved Egit issue).
So, in the end I deleted files locally (leaving the project all in bugs), committed and pushed it to the github, and then undid the delete locally and added files to .ignore.
Very unelegant, but it worked.
I lost a lot of time and nerves on it, and I hope this helps someone.

Another option, similar to what Sri Sankaran suggests in the comments, is to update the index in order to assume no modification to your config file:
On the preferences, in Egit, you can list "assumed unchanged" files
:
The file remains versioned and on the disk, but no modification will be detected on it.

If you need to delete invisible folder(or file) from eclipse project:
Add folder(or file) to .gitignore file;
Replace folder to another directory
Team add to index, commit and push
Replace folder(or file) to the project folder

Related

How to end 'another git process' running in same repository?

After my first attempt at committing a couple of large folders (angular and django), git responded with:
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Previous posts recommend:
removing the index.lock in the .git folder.
I've done this, but the second that i resubmit "git add . " as part of my git push origin master routine, the index.lock file reappears in .git
Is there another solution? And what has happened to warrant this?
I've tried all the suggestions in the commented link
I'm working with this:
git version 2.13.5 (Apple Git-94)
In my case, index.lock wouldn't delete. Instead, I found that one of my django folders lacked a .gitignore, so I created one and included the following files:
include
lib
include
bin
.vscode
You might want to include more or less, depending.. Apparently, I was attempting to push a file that disagreed with git.

git rm -f after add, before commit, on windows cmd line. Was open earlier in STS (Eclipse). Can recover?

I wanted to unstage files (as my .gitignore was not set up to ignore some of my IDE files) but in hurry did :
git add w3
//got some .settings etc folder and files added, in newly added sub folder w3
//the repo here already had sub folders w1 & w2.
Then issued:
git rm -f w3/*
I'm on windows 8. The files are hard deleted (not in the recycle bin). Any thing I can do with git or any other (free) way?
Edit Add
* Also it was opened in STS(eclipse) but now deleted the pom, settings everything. Anyway to restore from within eclipse?
Un-commited but added files are still in a repository for a while, however it would be quite tricky to restore it especially for a large old repository as usually it has a lot of garbage. So, if you don't mind dig into garbage, start with git fsck and look for dangling blob.
However, seems you cannot restore names of lost files, only content.
If the file was not versioned you can't restore it. See the documentation of git-rm. See here for how to undo adding a file to the staging area.
If the file was versioned you can retrieve it from a past commit. See this answer for more information.
Of course if you back up your drive you might be able to restore it with your back up program. For that you might get help over at SuperUser.

Can't add new file to repository in EGit

I'm using EGit with Eclipse Juno.
I worked with a local repository and the world was good.
Even adding a GitHub repository seemed to be fine. I added it to my local repository under "Remotes", so I can easily push commits to github.
But after a while, I noticed that no new files are added to the repository, even if I'm commiting changes.
They just are not under version control. They have no symbol, which should mean they are ignored.
This is my .ignore
.gwt
gwt-unitC
ache
Versandanzeige_Web_proto.war
Versandanzeige_Web.war
war/ajax
war/WEB-INF/classes
war/WEB-INF/deploy
www-test
The files are in src, so not even close.
The new files don't appear in the Commit-Dialog, even when checking "show untracked files". They don't appear in the Staging-Window.
RK -> Team -> "Add to index" doesn't help.
The files have the same right and are owned by the same user
They definetly dont show up at github
Any ideas how to fix that? Any additional information needed?
Update:
There are no errors in the error log.
I do have (HEAD) next to my newest branch.
More details:
I got my trunk T, beginning at T0. At T1, there is a branch A, which has changes to T1.
At T2, there is another branch, B. It has no changes to T2.
The strange thing: it is not indicated in History view. The master branch is also missing.
I can still switch to them. When I do git reflog, there are no entries before or including T2, just everything afterwards.
I removed the branches without commits:
The new files are still shown as ignored:
Output from command line:
$ git branch -a:
* master
maven
$ git status
# On branch master nothing to commit (working directory clean)
About the detached HEAD proposel: I didn't do what is described in the article, checking out an old state and work from that. And I can't see any undone commits.
Sorry for my bad english, I didn't use it for a while. Please ask for clarification, if I write something hard to understand.
Update:
I could add a file in another folder (/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar).
Alright, I found the error.
For some reason I don't really know, there was another .gitignore file ABOVE my Project folder (in repository folder), where my COMPLETE project folder was included. I really don't know how that happened. Of course, this file didn't show up in Eclipse.
I tried to add the files on the command line, but gut the error message "File is in .gitignore file".
After deleting that file, it worked find.
Sorry for the trouble.
Sometimes EGit does not work properly and add to index does not work. In that kind of situations you can go to the root folder of your project (where .git folder is placed) with a file explorer, right click on an empty area inside the folder, select "git bash". This will open the git console for you. Now type "git add path_to_file". This will add the file to the git system for indexing. Now go and refresh your project in eclipse and you will see it is added to the index. This can be used wile resolving conflicts inside eclipse because adding to the index indicates "mark as merged" to the git system by re-adding the merged file.
Also sometimes the "Remove from index" does not work in eclipse, you can do the same thing in that kind of situation: this time write "git remove --cached -f path_to_file". Here do not forget to add "--cached" because otherwise your file will be deleted. -f stands for "force" to force the command. For any folder (directory) to remove from index type "git remove --cached -r -f path_to_folder".

Mercurial will not recognize new folder in repository

I have an existing repo which has been setup correctly and working fine. I deleted an entire project folder from the repo, committed the change, then added another version of the same folder which was not under VC. Now when I try to add or commit files in the new folder, Mercurial does not seem to recognize any of the new files.
Using the TortoiseHg Windows Explorer "commit" extension, when I try to the commit the folder(or any of the files within), no files show up in the dialogue. If I right click and commit a file within the folder, a pop up comes up that says "No files found for this operation". I am no Hg expert, although I have been using it for few months without a hitch, but I am pretty stuck on this one. Any ideas?
UPDATE: I have added a screenshot below showing what happens when I try to add the new folder. None of the files in the folder seem to be recognized.
The project I had copied had been a part of another repo, so it contained hg reference files. I deleted these, and everything added/committed perfectly.
If you want to commit a new file to a repository, you must first add it.
On the command line this can be done in various ways :
hg add which can add a file or a repository and every files it contains.
hg addremove which adds all new files and remove deleted ones.
hg commit -A or hg commit --addremove which are the same thing and a shortcut of hg add remove; hg commit.
I don't remember exactly where the command is in TortoiseHG, but I think if you right-click on the folder in the explorer, the option should be present.
I think I also remember an addremove option somewhere in the commit window, but I may be mistaken.
[UPDATE]
Based on the answer you provided yourself, here is the explanation of why simply adding the files weren't working :
Since the new directory contained repository related information (a .hg directory), Mercurial was treating it as a Subrepository. Subrepositories are repository contained in another, this can, for example, be used to reference a specific version of a library.
Once you delete the .hg directory in your new location, Mercurial didn's saw this as a Subrepo anymore and you were able to add the files normally.

Get eclipse CVS to forget about removed directory

I'm looking for a way to convince Eclipse that a directory has indeed been removed from the CVS repository, permanently?
With regular command line CVS I would just edit CVS/Entries in the directory's former parent. With Eclipse, I've tried removing the directory from the Project Explorer view, removing the appropriate line in CVS/Entries, recreating the directory in PE so that it might be removed on update or synchronization, synchronize without recreating the directory, and probably other things that I've since forgotten, and nothing worked.
The directory has been entirely removed from the CVS repository, so I'm not talking about just pruning empty directories here. The error I am seeing is:
The server reported an error while performing the "cvs update" command.
Project: cvs update: cannot open directory /usr/local/cvsroot/one/two/three/removed_directory: No such file or directory
My project contains all of the contents from /usr/local/cvsroot/one/two. I do not get this error when I navigate to "three" and update from there. I only get it when I update from the project root.
One (quite imperfect) solution for this problem is, beside to check-out the project again, to remove CVS information stored by Eclipse.
Go in the right-menu under the project > Team > Disconnect, and check the radiobutton "Also delete the CVS meta information from the file system". Now your project is unshared and has no more CVS information into it. Then you just have to do Team > Share project, select the previous repository location, and you're done (CVS will detect by itself that the project is up-to-date and won't update nor commit anything, of course).
A folder that has been deleted in the cvs repository by hand won't then be proposed anymore by CVS under Eclipse to be commited.
Beware that on a big project with many files, depending on the speed of your network, the re-share may take some time.
Sometimes it may indeed be easier to delete the project and pull it off again from CVS.
I fought this same thing for several hours a couple of separate times. I just gave in and re-checked out the project. That seemed to work like a charm
Handling of directories in CVS is not perfect. This and many other reasons caused in creating more complete SCM tool subversion.
CVS can create directory, but can not remove it. From CVS point of view, to remove directory you need to remove (cvs rm) all files in directory. But directory is still present in CVS and there's no way to remove it. Hovewer, CVS propose a "hack" to hide such "deleted"/empty directories by executing "cvs up -P" (see here).
So, for CVS command line, I wouldn't mess with parent directory CVS/Entries file, but rather use "cvs up -P" described above.
The directory will be listed in the CVS/Entries file under the parent directory. Remove the entry in the Entres file and the directory. Eclipse should recognize the directory has been removed.
Refactoring directories in CVS is problematic. Due to the way CVS handles history one of the following usually applies:
The history of files moved to new locations appears to disappear. (It is located in the history of the old location.)
The history of files is retained, but files appear moved when checking out versions prior to the move. (Files were moved in the repository, rather than in a sandbox.)
Removing or moving directories in the repository generally creates problems for clients. It helps to retain directories and only move or remove files. Normal processing moves deleted files to an Attic sub-directory.
In the Eclipse CVS synchronization perspective, did you try the 'Override and update' option?
If the files/folders are already deleted on the repository, from the Eclipse project perspective, "replace with"->"latest from HEAD" on the folder containing deleted elements