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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With