0

I've got a .net solution directory (on OSX using a virtual machine) and just did a

$ git add .
$ git commit

on the whole directory.

I forgot there were a number of file and directories I didn't want added, such as my _resharper directory, and the contents of my bin folder.

So now, how do I first remove those directories and files from my local git repository without deleting them from my working copy?

Additionally, how do I add said directories to an ignore list?

andy
  • 8,775
  • 13
  • 77
  • 122
  • possible duplicate of [How do I untrack tracked files in git?](http://stackoverflow.com/questions/4178726/how-do-i-untrack-tracked-files-in-git) – Mat Jan 16 '12 at 06:58
  • Duplicate of: [Remove directory from remote repository after adding them to .gitignore](http://stackoverflow.com/questions/7927230/remove-directory-from-remote-repository-after-adding-them-to-gitignore) – lepe Mar 06 '14 at 05:27

2 Answers2

1

create a .gitignore file in the same directory as the repo. And put

_resharper/
*file.cpp

*remember the slash after the directory name for folder names, no need asterisk

by the way, you will need to remove the folder, untrack and then put it back in if you already add and commited.

You can learn more from here and here

Community
  • 1
  • 1
cctan
  • 2,015
  • 3
  • 19
  • 29
1
git reflog
git reset @HEAD{x} # x depends on what you see in reflog 
#edit .gitignore
#add line in gitignore 
#_resharper/
Luka Rahne
  • 10,336
  • 3
  • 34
  • 56
  • thanks ralu. If I add bin/ to the ignore file, will it ignore it even though the bin folder isn't in the working dir? – andy Jan 16 '12 at 07:59
  • Yes I usually edit .gitignore in .git folder and I am using GitExtensions on windows and gitx on linux to visualise what is going on before staging. You might try whit gitx on osx. – Luka Rahne Jan 16 '12 at 11:29