8

I have a local folder that is under git, when I was playing with some git stuff in different IDES, etc it got added to the git but I don't want it to be under git control, I just want it to be a normal folder for now! until I decide to add it to some repo later.

I am new to git so don't know much commands but if I run a git status command this is what I get:

git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   .idea/vcs.xml
#   new file:   .idea/workspace.xml
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .idea/workspace.xml
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .idea/.name
#   .idea/.rakeTasks
#   .idea/HisFirstService.iml
#   .idea/dictionaries/
#   .idea/encodings.xml
#   .idea/misc.xml
#   .idea/modules.xml
#   .idea/scopes/
#   Gemfile
#   Gemfile.lock
#   README
#   Rakefile
#   client.rb
#   config/
#   db/
#   models/
#   service.rb
#   spec/
3
  • Which folder do you want to remove? .idea? Commented Jan 30, 2013 at 23:45
  • You can create a file named .gitignore, which as its name suggests... Read more on the git manual ;] Commented Jan 30, 2013 at 23:46
  • @CarlNorum I am inside the HisFirstService folder and these are all files inside that folder. So I want to remove HisFirstSerivceFolder from git control. Commented Jan 30, 2013 at 23:47

5 Answers 5

13

It sounds like you want to remove a git repository that was automatically created by an IDE. (Note that git doesn't track folders, only files.)

If that's the case, just remove the .git directory and you'll be left with a folder that isn't tracked by git at all.

Sign up to request clarification or add additional context in comments.

Comments

7

Use git rm --cached to remove this directory from repository (it should stay in your working directory) and then put it's name into .gitignore file. At the end commit both .gitignore and directory removal.

1 Comment

Full command is git rm --cached -r <directoryNameOrPath>. -r will run "recursive" and ensure the files in the directory are also removed from your git repository. Be sure to run the command from inside the git repository in question; for example if using the BASH shell and the git repository is inside /folder/repository, first use cd /folder/repository to move to that folder.
1

Note that git does not store directories; it only stores files. This means that if you have committed any files from the subdirectory into your git repository, then you need to remove them with git rm <filename>. You also need to follow the instructions given by git status to remove files from the index. For example, git rm --cached <filename> will remove the new files so they will not be committed. Finally, you need to create a .gitignore file with the name of the directory which you don't want to have in your repo. This will make all future git commands ignore it.

Comments

1

If you are using the terminal and have multiple files which are deleted to be removed from git, do this:

git status | grep [d]eleted | awk '{print $3}' | xargs git rm --cache

Comments

0

Create a file named .gitignore and add the path of the folder you want to ignore (end with a "/").

Complete doc : https://help.github.com/articles/ignoring-files

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.