gpt4 book ai didi

git - 推送到远程存储库的当前分支会更新远程的工作目录吗?

转载 作者:太空狗 更新时间:2023-10-29 13:21:38 27 4
gpt4 key购买 nike

假设下面的远程仓库有一个工作目录,所以它也有一个当前分支。

  1. 这样说对吗

    • git push 可以推送到远程仓库中的当前分支,并且
    • 发生这种情况时,git push 不会更新远程存储库的工作目录

    我的想法来自使用 Git 的版本控制,作者 Loeliger,2ed,特别是粗体文本:

    Recall that the git push command does not check out files in the receiving repository. It simply transfers objects from the source repository to the receiving repository and then updates the corresponding refs on the receiving end.

    In a bare repository, this behavior is all that can be expected, because there is no working directory that might be updated by checked out files. That’s good. However, in a development repository that is the recipient of a push operation, it can later cause confusion to anyone using the development repository.

    The push operation can update the repository state, including the HEAD commit. That is, even though the developer at the remote end has done nothing, the branch refs and HEAD might change, becoming out of sync with the checked out files and index.

    A developer who is actively working in a repository into which an asynchronous push happens will not see the push. But a subsequent commit by that developer will occur on an unexpected HEAD, creating an odd history. A forced push will lose pushed commits from the other developer. The developer at that repository also may find herself unable to reconcile her history with either an upstream repository or a downstream clone because they are no longer simple fast-forwards as they should be. And she won’t know why: the repository has silently changed out from underneath her. Cats and dogs will live together. It’ll be bad.

  2. 如果我的想法是正确的,git push 是唯一的 git 命令吗更改时不会更新工作目录同一存储库的当前分支?还有哪些类似的 git 命令? (对我来说,其他命令对当前分支进行更改将更新工作同一存储库的目录。)

最佳答案

  • git push can push to the current branch in a remote repository, and

  • when that happens, git push doesn't update the working directory of the remote repository?

通常在 git 服务器上你有一个裸仓库。 Bare 表示您没有 git 文件系统,而是该文件夹包含 .git 文件夹的内容。

Recall that the git push command does not check out files in the receiving repository. It simply transfers objects from the source repository to the receiving repository and then updates the corresponding refs on the receiving end.

这是正确的,因为您没有工作文件夹,您没有任何文件,所以在推送期间没有内容被 check out 。


@VonC 在之前的问题中已经回答过您:

Since Git 2.3+, you can configure the receiving end to "have a working directory with a branch checked out in the receiving repository."


... To me, all other commands that make change to the current branch will update the working directory of the same repository.

同样,通常在远程服务器上,存储库是一个裸存储库,因此没有文件被 check out 到工作目录。


总结

因为 git 是分布式版本控制系统,没有人会直接编辑共享集中存储库中的文件。取而代之的是,开发人员将克隆共享的裸存储库,在本地存储库的工作副本中进行更改,然后返回到共享的裸存储库,以使其他用户可以使用他们的更改。

关于git - 推送到远程存储库的当前分支会更新远程的工作目录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34577888/

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