gpt4 book ai didi

git - 在 pull 之前提交所有内容,为什么?

转载 作者:太空狗 更新时间:2023-10-29 13:56:35 25 4
gpt4 key购买 nike

在分支机构工作时,我会更改一些文件。我的一位同事告诉我,他 push 了一项更改,我应该取消该更改以解决眼前的问题。如果我不提交更改,git 不会让我 pull 。即使我修改的所有文件都没有更新。

我想知道为什么会这样,如果可能的话,有没有办法避免这种情况?

最佳答案

git pull 本质上是一个获取,然后是一个 merge 。 merge 通常要求工作目录处于干净状态;他们这样做是为了您的安全:

Warning: Running git merge with uncommitted changes is discouraged: while possible, it leaves you in a state that is hard to back out of in the case of a conflict. (source)

和:

If any of the remote changes overlap with local uncommitted changes, the merge will be automatically cancelled and the work tree untouched. It is generally best to get any local changes in working order before pulling or stash them away with git-stash. (source)

我相信纯 git merge 中的检查实际上比 git pull 中的检查更宽容,因此您可能想尝试先获取然后手动 merge 。但先把东西藏起来总是更好的主意。

关于git - 在 pull 之前提交所有内容,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13767309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com