当我使用我的源代码工作时,我做了我惯常的事情提交,然后我推送到远程存储库.但后来我注意到我忘了在源代码中组织我的导入.所以我做了修改命令来替换以前的提交:
> git commit --amend
Run Code Online (Sandbox Code Playgroud)
不幸的是,提交不能被推回到存储库.这被拒绝了:
> git push origin
To //my.remote.repo.com/stuff.git/
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to '//my.remote.repo.com/stuff.git/'
Run Code Online (Sandbox Code Playgroud)
我该怎么办?(我可以访问远程存储库.)
这就是我在我所谓的稳定分支上所做的事情......
% git rebase master
First, rewinding head to replay your work on top of it...
Fast-forwarded alpha-0.3.0 to master.
% git status
# On branch alpha-0.3.0
# Your branch is ahead of 'origin/alpha-0.3.0' by 53 commits.
#
nothing to commit (working directory clean)
% git push
Fetching remote heads...
refs/
refs/heads/
refs/tags/
refs/remotes/
'refs/heads/master': up-to-date
updating 'refs/heads/alpha-0.3.0'
from cc4b63bebb6e6dd04407f8788938244b78c50285
to 83c9191dea88d146400853af5eb7555f252001b0
done
'refs/heads/unstable': up-to-date
Updating remote server info
Run Code Online (Sandbox Code Playgroud)
这是我后来意识到的一个错误.我想撤消整个过程,并将alpha-0.3.0分支恢复到原来的状态.
我该怎么办?