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

"git rm -r" with globbing

I'm trying to use git rm as part of the filter-branch. I want to delete directories */*/dir1 but nothing is happening. The command I'm using is: git filter-branch --tag-name-filter cat --index-filter "git rm -r --cached --ignore-unmatch */*/dir1"…
Michael
  • 1,014
  • 2
  • 15
  • 26
2
votes
3 answers

File removed using git rm --cached, but git still pushes it to my repo?

I have removed my file using git rm --cached and git reset HEAD. But when I try to push it to my repo, it still adds that file? How can I completely remove that file?
shader
  • 71
  • 1
  • 9
2
votes
3 answers

How can I remove all instances of a certain filename from a Git repo?

I have some files, for example one being error_log and some of these may have accidentally been added to git before they were added to the .gitignore file so I am wondering how can I delete all instances of files with this name from a Git repo? Note…
Brett
  • 19,449
  • 54
  • 157
  • 290
2
votes
1 answer

recover file after git rm with no previous history

Not sure there´s a solution to this: I accidentally staged a directory with: git add * then, upon seeing this, I did (major, major mistake, should have of course unstaged) git rm -r my_directory To top it all, I followed up with: git commit -m…
elelias
  • 4,552
  • 5
  • 30
  • 45
2
votes
1 answer

Git: cannot run git 'rm -rf . --cached'

I'm working with Rubygems, and it's caching files in git a lot. The easy solution is just to run git rm -rf . --cached, but when I run it, this message appears: fatal: pathspec '' did not match any files Even if I run git rm -rf ./\* --cached, it…
beakr
  • 5,709
  • 11
  • 42
  • 66
1
vote
0 answers

Removing a submodule manually

I tried removing manually the following submodule from my local repository: components/CtrlFuelSuppHtr Removed it from these three places: .git folder, components folder, and deleted it on .gitmodules. But I get the following error when running any…
tadm123
  • 8,294
  • 7
  • 28
  • 44
1
vote
0 answers

How to remove a submodule from git so that it is deleted from the file system on pull

I have a submodule named my_submodule, which I would like to delete. I need to make sure that it is removed from other developers' file systems as well, to prevent accidentally using it. I can't require the other develpers to run any extra commands…
justauser
  • 11
  • 4
1
vote
2 answers

git add/rm files based on the type of change (of the files)

Is there a way to stage or unstage (git add / git rm) files only based on what was the type of modification? Like : add/rm only files that are deleted add/rm only files that are new add/rm only files that are modified add/rm only files that are…
eshirvana
  • 23,227
  • 3
  • 22
  • 38
1
vote
1 answer

Easily remove multiple tracked files and add them to gitignore with VSCode

I have a folder with many files tracked by git, and I would like to untrack many of theses files in a simple way. Usually when I compile my solution, I see from VSCode source control tab some tracked files that shouldn't be. It's easy to select them…
PLB
  • 197
  • 1
  • 10
1
vote
2 answers

Git: how to untrack files without staging them for deletion

I have some config files that I want to change locally but not risk accidentally committing those changes. They also cannot be added to gitignore because they need to be tracked for the project as a whole. When I modify those files to suit my…
Andrew Toups
  • 189
  • 10
1
vote
2 answers

Can't remove all files with "git rm -r -f {folder_name}" (Windows 10)

I'm working in a git repository on Windows 10, and I have a folder named "Client" - I'm trying to completely delete it and all files inside it from my local repository. I'm inside the branch that I want it deleted from, and I ran the following…
jbyrd
  • 5,287
  • 7
  • 52
  • 86
1
vote
1 answer

Stop tracking file locally, but let other repo users keep tracking it?

I'm collaborating on an IntelliJ IDEA project using Git and GitHub. The original creator of the repo added the IntelliJ .idea folder to the repo, and I find it annoying to see changes to IDE files constantly popping up in the commit dialog. The…
Magnus
  • 17,157
  • 19
  • 104
  • 189
1
vote
4 answers

Git recover files

I added local files to git repo (git add .) and committed. Then deleted files with git rm * and committed again (second commit). That deleted files both locally and remotely. Hot to get files back into same local folder from git (from a first…
Joe
  • 11,983
  • 31
  • 109
  • 183
1
vote
1 answer

What is the difference between git rm and git rm -f?

I am reading book Git Pro and it says: To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your…
Ishan Patel
  • 5,571
  • 12
  • 47
  • 68
1
vote
2 answers

How to safely remove files from master which have already been removed from a branch?

Refer to the following diagram: my-branch A---B---C---D / \ master E---F---G During the merge from B to G I have inadvertently added files to master which I deleted from my-branch at D using git rm. Unfortunately, I…
scherm
  • 130
  • 4