我将本地主分支重置到一个提交点,使用以下命令:
当我输入
git reset --hard e3f1e37
当我输入
$ git status
命令时,终端会显示以下信息:# On branch master
# Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
nothing to commit, working directory clean
由于我也想重置起点/标头,因此我检出到 origin/master:
$ git checkout origin/master
Note: checking out 'origin/master'.
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 2aef1de... master problem fixed for master. its okay now.
通过此命令重置标题:
$ git reset --hard e3f1e37
HEAD is now at e3f1e37 development version code incremented for new build.
然后我试图向origin/header添加提交,但没有成功。
$ git commit -m "Reverting to the state of the project at e3f1e37"
# HEAD detached from origin/master
nothing to commit, working directory clean
最后,我将代码检出到我的本地主分支。
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
由于我重置了origin/master的head,所以我期望本地和origin应该处于相同的方向,但是如你所见,git说我的local/master比origin/master落后7次提交。
我该如何解决这个问题?我想要的是local/master和origin/master指向相同的提交。以下图片展示了我做了什么。谢谢。