Git doesn't really track folders - it just tracks files.  You'll see a
folder listed as untracked in the output of git status, but that's
just a simplification so you don't see the whole list of untracked
files inside it.  Presumably you have one or more tracked files inside
the folder.  You're right, though, git rm --cached is what you're
looking for.  As stated in the man page, it removes paths "only from
the index."  If you want to get rid of everything in the folder, you
can use "git rm -r --cached <dir>".  git status will then indicate as
changes to be committed the removal of the files, but they will also
be listed as untracked files (grouped as a directory), since they have
been left in the work tree -- unless you've already got them in
the .gitignore.

Note that if you do something like this and make the mistake of
forgetting the "--cached", thus removing them from the work tree as
well, all is not lost.  You can still commit the result, and then use
"git checkout HEAD^ <dir>" to check out the directories contents from
the previous commit (before they were deleted).  This adds them to the
index too, though, so you'll have to follow it with a "git reset HEAD
<dir>".  The default mode of reset is to modify the index but not the
work tree, so it removes them from the index but leaves them in the
work tree.

Jeffrey

On Jul 29, 1:25 pm, ryanl <rwlo...@gmail.com> wrote:
> Hey guys, is there a cool git command to remove a folder from the git
> repo, but not delete the file (like git rm)
>
> Basically, i want to ignore a folder, but the folder is already being
> tracked.
>
> I know i can mv the folder, commit, add the original path to the git
> ignore, then mv it back and it will be ignored, but i hoping for a
> better way.
>
> will git rm -cached do that?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to