15

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.

Git Changes

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!

Karl Gjertsen
  • 4,690
  • 8
  • 41
  • 64
  • 1
    this does not answer your question, but I too made this transition about 6 months ago and realized Visual Studio's support for git is pretty bad. Two months ago I discovered SourceTree (Atlassian) and it works much better. I hope you look into it as an alternative route at least until Visual Studio jumps aboard the git train. – Rob S. Jun 06 '16 at 14:11
  • Do you want to completely remove the file from the repository? – Tim Biegeleisen Jun 06 '16 at 14:12
  • The file is a temporary file. I t updates every time a change happens in WebStorm, so I am happy to lose the entire folder. – Karl Gjertsen Jun 06 '16 at 14:21
  • @RobS. I can't believe how hard I am finding the transition. As a long time VS and TFS / VSO user, TFs seems much more user-friendly. Everyone seems to love Git, but I am still trying to find out why! I'm sure I must be missing something. – Karl Gjertsen Jun 06 '16 at 14:38
  • 1
    @KarlGjertsen after using both I prefer Git, but Visual Studios implementation of Git can be very discouraging, but stay in there I'm sure you'll come around one day. – Rob S. Jun 06 '16 at 18:29

2 Answers2

21

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.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
1

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:

  1. If the files under changes are visible in the right pane(Git Changes), right click and delete from there.
  2. If the file is manually deleted directly from the local repo by you already, delete won't be available for that file, but a change will still be present in the Changes pane. In this case, click on '+' to stage the particular deleted file(you can select multiple files from the right side changes pane for this. This will move the particular change to the 'Stages' pane above the changes pane. Afterwards, click on Stash(this temporarily keeps(shelves) the file(s) apart for future tryouts). Now if you don't want this at all for the future, right click the item in the Stashes pane and click 'Drop' from the Stashes pane beneath the changes pane) and you're done.
octoberMan
  • 11
  • 2