我向我的仓库添加了一个新的遥控器。然后,我执行git reset --hard d3d52cee3cf112f30bd4a19611ed34e025d10120
来强制HEAD
重设,并且它起作用了。我继续工作。在采取其他措施之后,我尝试将自己的作品推向原点,但失败了。当我尝试解决问题时,会产生冲突,在解决冲突之前,我会git rebase --abort
并放松我在这两次之间提交的所有内容。我该如何找回在运行命令git rebase --abort
之前所做的一切?
这几乎是我所做的一切:
mustaq@Dell /opt/lampp/htdocs/wee $ git push origin master
^C
mustaq@Dell /opt/lampp/htdocs/wee $ git remote add origin
https://hellomustaq@bitbucket.org/mobilelili/laravel2.git
fatal: remote origin already exists.
mustaq@Dell /opt/lampp/htdocs/wee $ git remote -v
origin https://sazaldhaka@bitbucket.org/mobilelili/laravelbackend.git
(fetch)
origin https://sazaldhaka@bitbucket.org/mobilelili/laravelbackend.git
(push)
mustaq@Dell /opt/lampp/htdocs/wee $ git remove rm origin
git: 'remove' is not a git command. See 'git --help'.
Did you mean this?
remote
mustaq@Dell /opt/lampp/htdocs/wee $ git remote rm origin
mustaq@Dell /opt/lampp/htdocs/wee $ git remote add origin
https://hellomustaq@bitbucket.org/mobilelili/laravel2.git
mustaq@Dell /opt/lampp/htdocs/wee $ git add .
mustaq@Dell /opt/lampp/htdocs/wee $ git commit -m "draft"
[master 7afb7d9] draft
6 files changed, 238 insertions(+), 89 deletions(-)
create mode 100644 resources/views/table.blade.php
mustaq@Dell /opt/lampp/htdocs/wee $ git status
On branch master
fatal: Could not open file .git/rebase-merge/done for reading: No such
file or directory
mustaq@Dell /opt/lampp/htdocs/wee $ git remote -v
origin https://hellomustaq@bitbucket.org/mobilelili/laravel2.git
(fetch)
origin https://hellomustaq@bitbucket.org/mobilelili/laravel2.git
(push)
mustaq@Dell /opt/lampp/htdocs/wee $ rebase --abort
rebase: command not found
mustaq@Dell /opt/lampp/htdocs/wee $ git rebase --abort
mustaq@Dell /opt/lampp/htdocs/wee $ git status
On branch master
nothing to commit, working directory clean
答案 0 :(得分:2)
您可以使用git reflog列出HEAD
所指向的提交。在这里,您可以在git rebase --abort
之前找到提交,并且可以强制HEAD
返回到提交。
示例:
$ git reflog
a9646cd HEAD@{0}: rebase: aborting
4821905 HEAD@{1}: rebase: checkout test
a9646cd HEAD@{2}: commit: 3
177bb91 HEAD@{3}: checkout: moving from test to master
4821905 HEAD@{4}: commit: 2
177bb91 HEAD@{5}: checkout: moving from master to test
177bb91 HEAD@{6}: commit (initial): 1
$ git reset --hard 4821905
HEAD is now at 4821905 2