mit*_*mit 2 git version-control workflow dvcs
有2个git存储库,A和B.
两者都只有一个主分支,并且都在本地检出并正在处理.
我从A推进B的主分支,我收到这条消息:
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning:
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning:
warning: To squelch this message, you can set it to 'warn'.
warning:
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
Run Code Online (Sandbox Code Playgroud)
如果我在B的签出主分支上工作,我该如何更新它,所以我看到A的变化?
如果已经没有提交B上的主人本地结账也有变化怎么办?
注意:我真的不明白上面的git消息."引起混淆"是否意味着,它是坏的并且可能导致数据丢失?或者它只是意味着它是一种不容易处理的情况,但我通常可以相信所有的变化都以某种方式保存,如果有必要我将能够解决冲突."看到变化后的变化"代表什么?它是否会失去一些变化?
对于我作为外国人来说,这种语言不是很清楚.
编辑:我刚刚在A上添加了一个文件并将其推送到B.在BI上接收文件被删除的状态.
处理这种情况的简单工作流程是什么?
可能导致的混淆是这样的:假设您在A的提交中添加了大量文件master并将其推送到B的master.然后,如果您更改到存储库的工作树B并运行git status它将说明您刚刚添加的所有文件都已删除.当然,它们还没有删除 - 你刚刚更新了当前分支和工作树,而没有触及索引.我觉得这对很多人来说都很混乱!(这也是消息通过"查看已还原的更改"的含义 - 从git状态看起来好像您已经恢复了刚刚推送的提交,只是因为工作树和索引现在位于分支后面.)
在这种情况下,如果你确信是git status在B为清洁你推入你的主分支之前,您可以重置工作树,并匹配与分支的新位置的索引git reset --hard.
但是,如果你在B中有未提交或未分阶段的变化,那么这会突然变得更加混乱,因为这些真正的变化很难从推动的"变化"中分辨出来 - 解开这些变化可能非常困难.
所以,如果你了解正在发生的事情,并且你很乐意处理这种情况,那就没关系.就个人而言,我几乎总是试图通过以下方式之一来避免它:
我想前两个中的一个就是你想要的.
| 归档时间: |
|
| 查看次数: |
1706 次 |
| 最近记录: |