I am unable to get rid of this state in which my repo is seem to be locked in. After a doing a reset to HEAD~1, I keep getting this notification about this single file being modified. 'add' and 'checkout' have not affect. I have core.autocrlf and core.safecrlf unset (empty).
Please see below:
$ git --version git version 1.7.9.6 (Apple Git-31.1) $ git status # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: a_file_name.cpp
The followings commands (ran individually) have no affect:
$ git checkout -- a_file_name.cpp $ git reset a_file_name.cpp $ git add a_file_name.cpp $ git reset --hard $ git clean -n <nothing> $ git clean -f <nothing> $ git status # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: a_file_name.cpp
and it goes on ...
Response to @Don's suggestion below (git rm), no change, but here is how it goes:
$ git rm error: 'a_file_name.cpp' has local modifications (use --cached to keep the file, or -f to force removal) $ git rm -f a_file_name.cpp rm 'a_file_name.cpp' $ git status # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: a_file_name.cpp # # Changes not staged for commit: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: a_file_name.cpp # $ git commit -m"tmp" [master 2a9e054] tmp 1 file changed, 174 deletions(-) delete mode 100644 a_file_name.cpp $ git status # Your branch is ahead of 'origin/master' by 1 commit. # # Changes not staged for commit: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: a_file_name.cpp #
Pretty much back to sq.1
Before you create a commit, you have to add the files you have changed to that commit. When you run the git status command before adding files to a commit, you'll see the changes not staged for commit message in the output of the command.
"Changes not staged for commit" means Some changes are not staged. So, to stage all changes perfectly, run this command: git add -A. Then, run this command: git commit -m "Update"
For all unstaged files in current working directory use: git restore . That together with git switch replaces the overloaded git checkout (see here), and thus removes the argument disambiguation. If a file has both staged and unstaged changes, only the unstaged changes shown in git diff are reverted.
git commit -a -m "message"
The -a option will add all tracked files with modifications
A round about way that worked for me, is to:
recreate the file that I deleted.
git add path/filename
git rm --cached path/filename
delete the file
git add .
git commit --amend # if not on an already pushed branch.
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