Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a folder from Git

Tags:

git

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/
like image 876
Bohn Avatar asked Jan 30 '13 23:01

Bohn


People also ask

Can we delete a folder directly on GitHub?

You can delete an individual file or an entire directory in your repository on GitHub. People with write permissions can delete files or directories in a repository.

Can I delete a folder in GitHub not local?

Using the git rm –cached Command We've mentioned that git rm FILE will remove files from the index and local working tree by default. However, the git rm command provides the –cached option to allow us only to remove files from the repository's index and keep the local file untouched. As we can see, the user-list.


2 Answers

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.

like image 36
Josef Kufner Avatar answered Sep 19 '22 12:09

Josef Kufner


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.

like image 82
mpontillo Avatar answered Sep 22 '22 12:09

mpontillo