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
0
votes
3 answers

Undo .gitignore changes

I previously ignored a folder, but now I would like to ignore its content only: How do I remove/modify some entries from my .gitignore file so that git will track them again? I tried updating the gitignore file and adding the folder with git add -f…
0
votes
0 answers

how to not pull a file that commited?

I have a zip file (contains jdk) that is already committed to the remote repo, I only use this file in the remote repo (as a cicd procedure) and what I want is that I will not be able to pull it (the zip file) from the remote, because in my local…
omer
  • 1
  • 1
0
votes
1 answer

Removing all the files in a branch with git?

Trying to run git rm -r * on a branch. I have dist in .gitignore, but still get this error: fatal: pathspec 'dist' did not match any files Thoughts?
Ole
  • 41,793
  • 59
  • 191
  • 359
0
votes
0 answers

I accidentally uploaded a windows pointer instead of the actual folder- how do I delete it?

I accidentally uploaded a windows pointer instead of the actual folder- how do I delete it? Here's my problem- I can't rm this folder. It's an issue because I can't upload the real folder because it already exists. My workaround is to upload a new…
user3573562
  • 191
  • 11
0
votes
1 answer

Remove all files associated with a repository, keeping other files

I have cloned a "dotfiles" Git repository into my home directory and I'm trying to remove all the files associated with it. How can I safely remove all files that belong to the repository without accidentally deleting any other files from my home…
R Harrington
  • 253
  • 2
  • 10
0
votes
1 answer

Git remove file from repo without deleting WHEN OTHERS PULL

Each developer in my team has an .idea file in the root of their local working copy. Somebody didn't have it in their global .gitignore (and it's not in any other .gitignores) so they've accidentally committed it to our remote repo. Now it is being…
benxyzzy
  • 315
  • 3
  • 13
0
votes
1 answer

Adding a single tracked file to .gitignore without deleting it?

I've just discovered that my .idea/myproject.iml file, which is checked in, contains a local path. I therefore need to add it to .gitignore and make git not track it anymore. I (and everyone else) would like to keep our local version of…
thebjorn
  • 26,297
  • 11
  • 96
  • 138
0
votes
2 answers

GitHub mistakenly deleted file - multiple branches committed at different times. How to handle?

The scenario below details where there was a deleted file on a remote git repo mistakenly. If you scroll through the commits below, the problem really came up in COMMIT 4 and actually in terms of whether it was unexpected/expected, I wonder if…
uh_big_mike_boi
  • 3,350
  • 4
  • 33
  • 64
0
votes
0 answers

Refactor files from the main repository to a submodule with history

Take a project with, say, the executable source in the main repository M and dependent libraries in several sub modules S1, S2, etc. The decision is made that some code in the executable should be migrated to the library in submodule S1 to make it…
cycollins
  • 415
  • 4
  • 11
0
votes
2 answers

Keep deleted files on git pull

In the couple of the commits I need to pull there are a couple of deletions. Those files belong to some basic project files that shouldn't be present in git repository (that was our mistake in the first place, yeah). So I am afraid that the…
anneteka
  • 33
  • 1
  • 7
0
votes
0 answers

Git replace an entire directory

I have a directory in git that needs to be replaced with a new one. The new directory has few files modified, removed and also few files same. E.g.: **Currently in the repo** DirA |-> FileA, FileB |->DirB | |-> FileC, FileD |-> FileE,…
Arthes
  • 79
  • 1
  • 8
0
votes
1 answer

GIT remove changes of specific commit from current HEAD

Assume I have recent changes added or not added to the index. Now I'm cherry-picking a specific commit without creating a new commit on my HEAD ... git cherry-pick -n How do I remove the cherry-pick changes from the index? I could do a git…
codekandis
  • 712
  • 1
  • 11
  • 22
0
votes
2 answers

un-deleting file after running "git reset" after running "git rm"

I accidentally ran git rm file to undo that I ran git reset HEAD which didn't restore the file, so then I ran git reset HEAD~1 which didn't seem to restore the file either (this should be easy...) Now I see this: Unstaged changes after reset: M …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Remove specific file from specifc commit when 'git filter-branch' fails

I can't commit in my working directory anymore because there are some huge files in the repo that weren't included in gitignore, so they have been carried over and over in many commits/revisions. I've followed the instructions at…
microwth
  • 1,016
  • 1
  • 14
  • 27
0
votes
0 answers

How to resize the remote repository without deleting all the commit history?

There are several very related question already on stackoverflow (a few are linked below) but I could not solve my particular problem. I share a repository with Co-workers who have pushed huge datafiles/images that increased the size of the remote…
Cleb
  • 25,102
  • 20
  • 116
  • 151