最佳答案
我用这个命令重置了我的本地主节点。
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/header,我签出到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的头,我希望local和origin应该在同一个方向,但如你所见,git说我的local/master落后于origin/master 7次提交。
我该如何解决这个问题?我要找的东西是本地/主头和原点/主点相同的提交。下图显示了我所做的。谢谢。