我在我的gh-pages
树枝上,当我
$ git add <file>
$ git commit -m "<message>"
我懂了
# On branch gh-pages
nothing to commit, working directory clean
然后我会做,看看以下
$ git stage
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
$ git status
# On branch gh-pages
nothing to commit, working directory clean
我试图深入挖掘以找出问题所在
$ git log
commit d7122828ef232829e28654f4bc56022829d03722
Author: siddhion <siddhion@gmail.com>
Date: Wed Jul 24 19:00:19 2013 +0200
1st push to gh-pages
$ git reflog
d712282 HEAD@{0}: checkout: moving from master to gh-pages
9bf529e HEAD@{1}: checkout: moving from gh-pages to master
d712282 HEAD@{2}: commit (initial): 1st push to gh-pages
我不确定这里发生了什么,但在此之前我试图摆脱我最后一次提交尝试以下命令
git reset --soft HEAD
git reset --hard HEAD
git reset HEAD
git reset .
git reset
也许我用这些让事情变得更糟。没有把握。我也试过
$ git push origin gh-pages
Counting objects: 1156, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1141/1141), done.
Writing objects: 6% (70/1156), 2.27 MiB | 680.00 KiB/s
然后我立即取消,因为我不想再提交/添加了。
如何恢复/删除最后一次提交/添加并重新开始?
更新
好的,我首先关注的是 John Galt 的回答。我跑了
$ git checkout d712282
得到了这个
Note: checking out 'd712282'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at d712282... 1st push to gh-pages
在这一点上,我真的不知道该怎么办。我只想回到我的gh-pages
分支,不再让那个大坝d712282
提交困扰我。所以那时我
$ git checkout gh-pages
愚蠢地我认为d712282
提交与分离的头一起死了,所以我像以前一样继续
git add index.html
但是当我检查是否已经上演时,我得到了
$ git stage
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?
在这一点上,似乎与以前没有任何变化,但我坚持只是为了彻底。当我尝试运行提交时,我得到了
$ git commit -m "added index.html to gh-pages"
# On branch gh-pages
nothing to commit, working directory clean
然后我做了
$ git status
# On branch gh-pages
nothing to commit, working directory clean
我想看看正在运行的东西$ git log
给了我什么
$ git log
commit d7122828ef232829e28654f4bc56022829d03722
Author: siddhion <siddhion@gmail.com>
Date: Wed Jul 24 19:00:19 2013 +0200
1st push to gh-pages
有同样的旧d712282
提交。我也跑了$ git reflog
,得到了
$ git reflog
d712282 HEAD@{0}: checkout: moving from d7122828ef232829e28654f4bc56022829d03722
d712282 HEAD@{1}: checkout: moving from gh-pages to d712282
d712282 HEAD@{2}: checkout: moving from d7122828ef232829e28654f4bc56022829d03722
d712282 HEAD@{3}: checkout: moving from gh-pages to d712282
d712282 HEAD@{4}: checkout: moving from master to gh-pages
9bf529e HEAD@{5}: checkout: moving from gh-pages to master
d712282 HEAD@{6}: commit (initial): 1st push to gh-pages
而这一点我尝试了杰弗里的建议,然后跑了
$ git reset --hard d712282
HEAD is now at d712282 1st push to gh-pages
所以在这一点上我想做的就是摆脱 d712282 因为每次我尝试git push origin gh-pages
git 开始推送 d712282 提交,它有 1156 个文件。太多了。我要它死。