git 我怎么能在 FETCH_HEAD 上倒带我的工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10526793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:54:03  来源:igfitidea点击:

how could I rewind my work on top of FETCH_HEAD

git

提问by Pan Ruochen

After I pulled from the remote repository, I got the following messages:

从远程存储库中提取后,我收到以下消息:

  • branch develop -> FETCH_HEAD First, rewinding head to replay your work on top of it... Fast-forwarded my_topic to f05183b231e55864ae8d99db9456167af3413b6a
  • 分支开发 -> FETCH_HEAD 首先,倒带头部以在其上重放您的工作...将 my_topic 快速转发到 f05183b231e55864ae8d99db9456167af3413b6a

So how could I rewind my work on top of FETCH_HEAD?

那么我怎么能在 FETCH_HEAD 上倒带我的工作呢?

回答by AD7six

The message is a confirmation of what git has successfully done - it isn't asking you to do anything.

该消息是对 git 已成功完成的确认 - 它不要求您做任何事情。

if you want to check that a branch contains a particular commit:

如果要检查分支是否包含特定提交:

git branch --contains <hash>

It's not related to the question as askedbut if you want to put commits ontop of others - that's where git rebasecomes in - to re-order commits.

它与所问的问题无关,但是如果您想将提交置于其他人之上 - 这就是git rebase进来的地方- 重新排序提交。

e.g.

例如

git checkout master
...
git commit -vam "one"
...
git commit -vam "two"
...
git checkout somebranch
...
git commit -vam "three"
...
git commit -vam "four"

Commits one+two and three+four are in 2 separate branches. to get them in order:

提交一+二和三+四在 2 个独立的分支中。让它们井然有序:

git rebase master

Alternatively, you can apply a single commit simply by doing:

或者,您可以通过执行以下操作来应用单个提交:

git cherry-pick <hash>

You can use git reflogto find the hash for any commit that you think is missing.

您可以使用它git reflog来查找您认为丢失的任何提交的哈希值。

回答by bill-x

Did you add and commit everything on your own side first? To check that, do a

您是否先添加并提交了自己的所有内容?要检查,请执行

git status

If you didn't, you should always do that first and then try pulling again.

如果你没有,你应该总是先这样做,然后再试一次。