I was trying to delete all the migration files on the master branch. Git prompted:
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
since I did not need the migration files, I typed:
git rm . -r
Git prompted:
error: the following files have changes staged in the index:
/middleware.py
project_management/models.py
sales/migrations/0001_initial.py
(use --cached to keep the file, or -f to force removal)
Thinking that the conflicts are just due to those migration files, I typed:
git rm . -r -f
Now, git has removed ALL my files, including models, templates, views, static files, etc.
rm '.gitignore'
rm 'accounts/__init__.py'
rm 'accounts/__pycache__/__init__.cpython-36.pyc'
rm 'accounts/__pycache__/backends.cpython-36.pyc'
rm 'accounts/admin.py'
rm 'accounts/apps.py'
rm 'accounts/backends.py'
rm 'accounts/forms/__init__.py'
rm 'accounts/forms/authenticate.py'
rm 'accounts/forms/register.py'
rm 'accounts/migrations/0001_initial.py'
rm 'accounts/migrations/__init__.py'
rm 'accounts/models.py'
rm 'accounts/templates/login.html'
rm 'accounts/templates/signup.html'
rm 'accounts/tests.py'
rm 'accounts/urls.py'
rm 'accounts/views.py'
Now, when I do
git status
It tells me this: On branch master All conflicts fixed but you are still merging. (use "git commit" to conclude merge)
Changes to be committed:
deleted: .gitignore
deleted: accounts/__init__.py
deleted: accounts/__pycache__/__init__.cpython-36.pyc
deleted: accounts/__pycache__/backends.cpython-36.pyc
deleted: accounts/admin.py
deleted: accounts/apps.py
deleted: accounts/backends.py
deleted: accounts/forms/__init__.py
deleted: accounts/forms/authenticate.py
deleted: accounts/forms/register.py
deleted: accounts/migrations/0001_initial.py
deleted: accounts/migrations/0002_auto_20170212_1028.py
deleted: accounts/migrations/__init__.py
deleted: accounts/models.py
deleted: accounts/templates/login.html
deleted: accounts/templates/signup.html
deleted: accounts/tests.py
deleted: accounts/urls.py
deleted: accounts/views.py
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
accounts/
commonapp/
There are more than 10 apps, with more than 50 models, etc. but for the sake simplicity, I have not list them all here.
Is there a way to undo these deletions? This is months worth of my time, so I really appreciate your help.