首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Git,如何将源/主节点重置为提交?

Git,如何将源/主节点重置为提交?
EN

Stack Overflow用户
提问于 2013-07-16 10:26:11
回答 3查看 300.5K关注 0票数 291

我使用以下命令将本地主机重置为提交:

代码语言:javascript
复制
git reset --hard e3f1e37

当我输入$ git status命令时,终端显示:

代码语言:javascript
复制
# 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

由于我还想重置源/报头,所以我签出到源/主:

代码语言:javascript
复制
$ 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.

并通过以下命令重置header:

代码语言:javascript
复制
$ git reset --hard e3f1e37
HEAD is now at e3f1e37 development version code incremented for new build.

然后,我尝试将提交添加到未成功的源/标头。

代码语言:javascript
复制
$ git commit -m "Reverting to the state of the project at e3f1e37"
# HEAD detached from origin/master
nothing to commit, working directory clean

最后,我结账到我当地的主人那里。

代码语言:javascript
复制
$ 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)

由于我重置了源/主的头部,我希望local和Since应该在同一个方向上,但是正如你所看到的,git说我的local/master比源/master落后7次提交。

如何解决此问题?我正在寻找的东西是本地/master的头和源/master指向相同的提交。下图显示了我所做的事情。谢谢。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17667023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档