Reputation: 4928
I am using Git with Visual Studio 2015 and I have a file that I want to remove, but I can't figure out how!
The file is a WebStorm settings file (workspace.xml), which I am using for working on the JavaScript fiels. This file was included as part of a previous Git Push, but I missed my chance at marking it as ignored.
I am happy to remove the parent folder: C:\WIP\xxxx\xxxx\app\.idea
.
I have lots of experience with Visual Studio and TFS, but this is the first time I have used Git. I'm sure the fix is very simple, but it is eluding me!
Upvotes: 18
Views: 36803
Reputation: 357
I could not delete the file present in Git Changes (using MSVS 2017) as suggested by @octoberMan (no such command in the menu and Del or Shift-Del did not have any effect).
If I deleted the file from the folder then it appeared in overstrike font in Git Changes. I performed a commit order form Git menu.
I added the file name in ".gitignore" file. After restarting Visual Studio it did not appear in Git Changes (the file has been already automatically recreated).
Upvotes: 0
Reputation: 11
Found out how to do it in Visual Studio Git. Unless the changes are either taken in or out VS won't let any commits happen.
This is to be done to accomplish the above:
Upvotes: 1
Reputation: 522646
If you want to retain workspace.xml
from the remote repository while keeping it locally as an untracked file, then this cannot easily be done from Visual Studio. Your best bet might be to do this from the command line. Try this:
git rm path/to/workspace.xml
git commit -m 'removed workspace.xml from repo'
git push origin yourBranch
These commands remove workspace.xml
from being tracked by Git and push this change to the repository.
If you don't mind deleting the file from your local setup, then you can delete workspace.xml
, commit, then push the change to the repository. This should be doable from within Visual Studio. If you still want workspace.xml
locally, then you can backup this file and add it after you push the remove.
Upvotes: 23