Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit deleting all files in repo

Tags:

git

For the second time today git commit -m "don't quit me now" deletes my entire repo. So it goes:

$ git add .
$ git commit -m "please, be gentle"

[master 7af0e9c] please, be gentle
140 files changed, 0 insertions(+), 3186 deletions(-)
delete mode 100644 .DS_Store
delete mode 100644 .gitignore
delete mode 100644 .rspec
delete mode 100644 Gemfile
...

I've been using Github for Mac alongside the command line and wondering if that's somehow effing things up.

$ git checkout
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    .DS_Store
#   deleted:    .gitignore
#   deleted:    .rspec
#   deleted:    Gemfile
#   deleted:    Gemfile.lock
like image 948
Jack Frost Avatar asked Apr 11 '12 05:04

Jack Frost


1 Answers

Since git status tells you that everything is staged for deletion, before doing anything else, reset the index to HEAD:

git reset HEAD

After doing this, git status should echo

no changes added to commit (use "git add" and/or "git commit -a")

Then, try again:

git add .
git commit -m "new try"
like image 174
eckes Avatar answered Sep 30 '22 21:09

eckes