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
16
votes
2 answers

Recover staged but not committed files after 'git rm -rf'

On my local machine I removed files from folder. git init git add --all then I wrote (don't ask me, why! :) ) git rm -rf I don't commit, yet. Now I have empty folders in my project. In .git folder has objects with 53 Mb of files. How can I…
user2003024
  • 191
  • 1
  • 8
15
votes
3 answers

Git: need to recursively 'git rm' the contents of all bin and obj folders

Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this?
Jacko
  • 12,665
  • 18
  • 75
  • 126
12
votes
2 answers

Git: Undo local changes; git add . + git rm?

Need help figuring out a couple common workflows with Github. I come from a VS TFS background, so forgive me. Undoing Pending Changes Let's say I have cloned of a git repository to my local file system. At this point, the project's local files match…
user979672
  • 1,803
  • 3
  • 23
  • 32
12
votes
3 answers

Git + Rails: How to restore files deleted with "git rm -r"?

I deleted my db folder in a rails application in with git rm -r I've tried git reset HEAD and git reset --hard HEAD but the migration files arent coming back. I tried commiting, then running the reset and still nothing. What should I do?
ChrisWesAllen
  • 4,935
  • 18
  • 58
  • 83
12
votes
5 answers

git undo deleted files

I am new to git. I have checkout files from remote. I had to delete few files from the git repo. Instead of doing git rm command, I issued unix rm -rf folder command. I need to revert the delete command and then perform git rm command. How to revert…
Pradeep
  • 753
  • 7
  • 15
  • 25
12
votes
5 answers

Cant rm folder with GIT rm?

I want to remove an entire directory with GIT ... each time I keep getting the same error and don't understand why this is happening. I want to remove the "blue_white" folder ... ├── css │   ├── design.css │   └── red_white.css ├── images │   ├──…
rsturim
  • 6,756
  • 15
  • 47
  • 59
11
votes
1 answer

Difference between `git rm --cached` and `git update-index --assume-unchanged`?

I do not understand the difference between git rm --cached and git update-index --assume-unchanged. I'm aware that git rm --cached will remove a file from the staging area. And, I know that git update-index --assume-unchanged also…
makansij
  • 9,303
  • 37
  • 105
  • 183
9
votes
3 answers

Git remove file from all commits

I made a "little" mistake and added a "little" (>100MB) file to my local repo. Two commits later I'm trying to push to remote repo in github that have a limit of 100MB. I can remove the file from my current commit with git rm --cached, but it still…
Mquinteiro
  • 1,034
  • 1
  • 11
  • 31
8
votes
3 answers

Impossible to git rm with special characters

I added files in my git repository that I want to remove now. I deleted it with rm XXX. Now, git status shows me: Changed but not updated: deleted: "Sche\314\201ma application + interface.graffle" No matter how I git rm it, I still have a…
kheraud
  • 5,048
  • 7
  • 46
  • 75
8
votes
1 answer

After git rm file; commit -- how to get file back from the remote branch?

I was pulling in my .emacs directory, and hit the following conflict: CONFLICT (add/add): Merge conflict in elisp/dired-details+.el Git status showed the following: Unmerged paths: # (use "git add/rm ..." as appropriate to mark…
Leo Alekseyev
  • 12,893
  • 5
  • 44
  • 44
8
votes
3 answers

Practical use case of 'git rm' and 'git mv' with git?

I know that git provides the 'git rm' and 'git mv' to remove/move files or directories. But, I can't see the practical use case for this. Normally, I just mv or rm the files or whatever in the command line, and after I'm done with all the necessary…
prosseek
  • 182,215
  • 215
  • 566
  • 871
8
votes
3 answers

git rm --cached everything that is listed in .gitignore

I added .gitignore to my project after I had everything commited. Now I want to run a command like: git rm --cached *everything_listed_in_gitignore* How can this be achieved? Thank you in advance.
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
7
votes
3 answers

Git - rm equivalent for "add ."?

If you're using Git from the command line, is there a way to delete in one fell swoop all the files to be deleted in the Changed but not updated list? Rather than doing manual removes using wildcards.
Steve
  • 5,802
  • 12
  • 54
  • 76
5
votes
2 answers

Can a "git rm -r -f " command be reverted?

I was setting up my first git repository and did the following, git init follow by some git-config stuff to setup the remote server. I then did git add directory git status Whoops, I added some files which I did not want. Okay, so I should git rm…
Duncan Drennan
  • 871
  • 2
  • 9
  • 21
5
votes
1 answer

Unable to stop tracking JetBrains .idea files

I have added the .idea files to my .gitignore file and that seems to work fine. Since my .idea files were tracked already, though, earlier posts have suggested the following code, to get them out from under version control. git rm -rf .idea or git…
Mike McGuire
  • 329
  • 3
  • 12