2017-03-24 8 views
0

何が起こったのか分かりません。私はコミットしようとしました。私がマスターするように押し進めたとき、私は最新であり、何も起こっていないと言いました。この後私は間違ってgitコミットを行うときにすべてを削除しました

(py35) $ git status 
On branch jt 
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: rt/models.py 
modified: rt/test_models.py 

Untracked files: 
(use "git add <file>..." to include in what will be committed) 

../.DS_Store 
.DS_Store 
rt/.DS_Store 
rt/migrations/.DS_Store 
rt/migrations/0005_auto_20170323_2255.py 
rt/migrations/0006_department_org.py 
rt/migrations/0007_auto_20170323_2309.py 
rt/migrations/0008_auto_20170323_2311.py 
rt/migrations/0009_auto_20170323_2313.py 
rt/migrations/0010_auto_20170323_2315.py 

no changes added to commit (use "git add" and/or "git commit -a") 
(py35) $ git add . 
(py35) $ git commit -m "edits to models, fixed up team and dept, tested with presentation and working paper" 
[jt cea85b9] edits to models, fixed up team and dept, tested with presentation and working paper 
Committer: Jonathan <xxxxxxxxxx> 
Your name and email address were configured automatically based 
on your username and hostname. Please check that they are accurate. 
You can suppress this message by setting them explicitly. Run the 
following command and follow the instructions in your editor to edit 
your configuration file: 

git config --global --edit 

After doing this, you may fix the identity used for this commit with: 

git commit --amend --reset-author 

11 files changed, 398 insertions(+), 79 deletions(-) 
create mode 100644 mysite/.DS_Store 
create mode 100644 mysite/rt/.DS_Store 
create mode 100644 mysite/rt/migrations/.DS_Store 
create mode 100644 mysite/rt/migrations/0005_auto_20170323_2255.py 
create mode 100644 mysite/rt/migrations/0006_department_org.py 
create mode 100644 mysite/rt/migrations/0007_auto_20170323_2309.py 
create mode 100644 mysite/rt/migrations/0008_auto_20170323_2311.py 
create mode 100644 mysite/rt/migrations/0009_auto_20170323_2313.py 
create mode 100644 mysite/rt/migrations/0010_auto_20170323_2315.py 
(py35) $ git push origin master 
Everything up-to-date 

私はダム何かをしたし、その後、彼らは私の最後のコミットにあったものにファイルを戻す

git log -1 
git reset --hard dd882d0aa067c60dd92610d1fa6b32548e70f596 

を走りました。 IDEで開いていたものを変更することさえできます。

私は今日取り組んでいた変更をすべて元に戻すことができますか?私が/.git/lost-found/otherを見ると、そこにいるので、彼らがそこにいることを知っています。私はそれらを使用する方法がわからない。

+0

'get reflog --all'は何かを与えますか?以前のHEADにチェックアウトすることができます。この[回答](http://stackoverflow.com/a/21778/1233686)を参照してください。 – hurturk

+0

あなたはbitbucketまたはgithubを使用しますか? git reset --hard [commit#] –

+2

'git reset --hard cea85b9'はあなたを元に戻します。 – 1615903

答えて

2

次のコマンドを実行すると、前回のコミットにHEADを指すことによって回復することができる:

git reset --hard [email protected]{1} 

だけで解決のための任意の混乱を防ぐために、このを入力する前に、プロジェクト全体のディレクトリのバックアップコピーを作成してください。

+0

一般に、 'git reflog'を使って、前回の' HEAD'の位置を知ることができます。 –

関連する問題