Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git won't commit because a deleted file doesn't exist

Tags:

git

It appears that I've somehow gotten git into a state in which it won't commit because a file that's been deleted doesn't exist:

~/src$ git status -u
# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#   deleted:    release-vars.sh
#
~/src$ git commit -a
fatal: pathspec 'release-vars.sh' did not match any files
~/src$ ls release-vars.sh
ls: cannot access release-vars.sh: No such file or directory

Any ideas on how to resolve this situation?

like image 681
Steve Emmerson Avatar asked Feb 03 '15 23:02

Steve Emmerson


1 Answers

-a is explicitly telling it to commit the current version of every currently-tracked file from the content in your worktree. It's not quite the same operation as

git add --all

which might be what you're after here. Then do an ordinary commit.

If your .gitignore specs leave unignored detritus you don't want to track you could instead git rm --cached the deleted file explicitly so your subsequent git commit -a doesn't trip over the unexpectedly missing file.

like image 186
jthill Avatar answered Nov 15 '22 05:11

jthill