我的分支上有一些错误 commit/push,然后我想恢复到旧的正确提交并将其推送到当前分支上。
我有以下问题:
git log
new: xxxxxxx
...
old: ac758a3
git checkout ac758a3
git commit -m 'revert to old branch (ac758a3) to push it on current branch'
Run Code Online (Sandbox Code Playgroud)
出去:
HEAD detached at ac758a3
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
[编辑]
我想恢复到 A(旧提交)并将其推送到当前分支(同一分支)。
什么是快速解决方案?
提前致谢。
git reset --hard <commit-id> 是你亲爱的朋友吗?
请按照以下步骤操作:
git loggit reset --hard <commit-id-copied-in-step-2 above>git push origin <my-feature-branch> -f。注意:您将无法正常推送,必须强行推送,因为我们更改了该分支的历史记录并且与远程不同步。
| 归档时间: |
|
| 查看次数: |
4196 次 |
| 最近记录: |