【发布时间】:2013-07-14 01:43:45
【问题描述】:
我通过这个命令将我的本地主机重置为提交:
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.
然后我尝试将提交添加到我没有成功的原始/标题。
$ 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 次提交。
我该如何解决这个问题?我正在寻找的东西是本地/主控和原产地/主控的负责人指向相同的提交。下图显示了我所做的。谢谢。
【问题讨论】:
-
首先,确保你被允许强制将代码推送到你的项目中受保护的分支,否则你将无法...
标签: git git-checkout git-reset