Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble deleting file from tracking using Git

Tags:

git

I have a weird problem with untracking file. I have a tracked file index.css. Then I add it to .gitignore. Then I run the following and get an output:

$ git rm --cached build/development/css/index.css
rm 'build/development/css/index.css'

Running git status gives the following:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    build/development/css/index.css

When try to commit changes I get the following error:

Error:On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
 during executing git commit --only -F C:\Users\dtv\AppData\Local\Temp\git-commit-msg-7154374096157077481.txt -- build/development/css/index.css

If I try to commit the changes to index.css along with outher changes, the commit goes without error. But changes to the file is still detected. What am I doing wrong?

like image 838
Max Koretskyi Avatar asked Sep 24 '14 13:09

Max Koretskyi


People also ask

How do I remove a file from git tracking?

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 working directory so you don't see it as an untracked file the next time around.

Can we delete file from git repository?

The "rm" command helps you to remove files from a Git repository. It allows you to not only delete a file from the repository, but also - if you wish - from the filesystem. Deleting a file from the filesystem can of course easily be done in many other applications, e.g. a text editor, IDE or file browser.


1 Answers

The problem is the --only option for git commit. From git-commit manpage:

Make a commit only from the paths specified on the command line, disregarding any contents that have been staged so far.

It tries to commit that file, disregarding the previous git rm --cached command from before.

like image 63
Jean Waghetti Avatar answered Sep 25 '22 01:09

Jean Waghetti