Questions tagged [git-rm]

`git rm` is a Git command used to remove files from the working tree and from the index. Use this tag for all posts related to the usage of this command.

git rm is a Git command used to remove files from the working tree and from the index. In particular, it allows to actually start ignoring the files, listed in .gitignore.

Recommended questions:

117 questions
5
votes
2 answers

How do I move an unstaged file to untracked?

Say this is what I'm looking at in git status: Changes not staged for commit: modified: Makefile.in Untracked files: ../node_modules/somepath/inverter_packet.js What I want to do is something like move Makefile.in from 'Changes not staged…
J.M. Janzen
  • 671
  • 1
  • 8
  • 19
5
votes
1 answer

Undo git rm . -r --cached or commit changes?

I was trying to make my .gitingore work (Link to the question :) ). I have just done git rm . -r --cached and now I have a whole list of deleted files when I enter: git status -s Is this normal? Can i safetly commit all my changes? Or maybe…
Mr.TK
  • 1,743
  • 2
  • 17
  • 22
5
votes
1 answer

git rm -r doesn't work in a submodule

Try to change submodule as described in git book $ git rm -r vendor/html-minifier $ git submodule add https://github.com/kangax/html-minifier.git vendor/html-minifier But it fails with following rm 'vendor/html-minifier' fatal: git rm:…
stereobooster
  • 460
  • 4
  • 11
4
votes
1 answer

Undo git rm -f [file]

I accidentally removed 3 files from both git and my working directory with git rm -f [file] when I was only trying to get git to ignore them. Is there any way to undo this command? The files have been changed since my last commit.
Frank Peelen
  • 55
  • 1
  • 7
4
votes
1 answer

When changing .gitignore, do all developers need to run `git rm --cached `?

If I add file that is already tracked by Git to my .gitignore, I can simply run git rm --cached to apply the new rules. I push that to the server, and the server will no longer receive my changes. Will I have to tell everyone on my dev team…
Morgan Delaney
  • 2,349
  • 3
  • 20
  • 23
4
votes
2 answers

How to undo a " git rm -r -f * "

I was using git for the first time, I had a directory with several programs written in it and did the following steps I did git add . then git commit, then it i got a message Aborting commit due to empty commit message. Then i thought, let me…
Manu
  • 5,534
  • 6
  • 32
  • 42
3
votes
3 answers

Why git rm --cached not remove local ever tracked file but others

When untrack a file in the git repository, use git rm -r --cached .. This will not remove the ever tracked file in local storage, but when other developers fetch this commit with git pull, the ever tracked file will been removed on their machine…
LF00
  • 27,015
  • 29
  • 156
  • 295
3
votes
2 answers

git blame deleted file, automatically

It is a common question how to run git blame on a file which has earlier been deleted (with git rm). If you just run it with the old filename then it gives the same error as for a file which has never existed: % git init % echo 1 >a % git add a %…
Ed Avis
  • 1,350
  • 17
  • 36
3
votes
2 answers

how to remove the existing versioned file from git

I want to avoid my fabfile.py from being versioned in git. I did these steps: copied file to fabfile.default.txt file as backup removed fabfile.py git rm --cached fabfile.py added fabfile.py into .gitignore then committed the removed file…
doniyor
  • 36,596
  • 57
  • 175
  • 260
3
votes
1 answer

Cannot `git rm` A Previously Tracked File

I have a developer on a Windows 8 computer who's installed git from Git-Scm who can't use git rm to remove files from his repo. git --version output: version 1.8.1.msysgit.1 When he attempts to untrack the file, he gets this message: fatal:…
AlbertEngelB
  • 16,016
  • 15
  • 66
  • 93
2
votes
1 answer

Remove all files from history that are not in working tree

Lots of answers on StackExchange deal with removing a given file from all commits in the history with something like: git filter-branch --prune-empty -d /dev/shm/scratch \ --index-filter "git rm --cached -f --ignore-unmatch filename" \ …
Cjen1
  • 1,826
  • 3
  • 17
  • 47
2
votes
5 answers

How to recover from "git rm -rf ." and still retain uncomitted changes?

I had a bunch of changes added to the staging index by git add *, but not yet commited, I wanted to remove them, undo the add, so I did git rm -rf . to my surprise it removed them from my hard drive, I want a way to get them back; however, I have…
aelmosalamy
  • 100
  • 9
2
votes
3 answers

Remove a file from whole git history

I know this question has already been asked, but in every answer, I found the situation is slightly different from mine and I don't see how to adapt it. So here is the problem: I cloned a repository and added a folder to work in it. In this folder,…
Wendy
  • 791
  • 1
  • 5
  • 8
2
votes
1 answer

Git - How do I delete files in upstream repo but not from my fork

I have forked a repo (called the original repo upstream) because there had to be done some cleanup but I wanted to keep the folder johannes I work with. So I went along and deleted that specific folder with git rm -cached -r johannes/ git commit -m…
johk95
  • 873
  • 10
  • 28
2
votes
2 answers

What does git-rm mean by working tree and index?

The documentation for git-rm contains this short description: git-rm - Remove files from the working tree and from the index What exactly is meant by the working tree and the index, and which local or remote files will be removed?
Joshua Lee
  • 45
  • 8