git checkout是否更新所有文件?

编程入门 行业动态 更新时间:2024-10-27 19:29:57
本文介绍了git checkout是否更新所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我 git checkout< revision> ,那么这会将整个项目返回到它的状态,还是只重新创建那个特定修订版中更改的文件?

例如:如果我的文件夹除了.git repo和I git checkout master 之外完全是空的,那么生成的文件将是其中的项目整体,还是只有在最近的提交中更改过的文件?

我问,因为我在各个点(从头开始)检查我的项目,该项目的规模正在缓慢增长,正如人们所预料的那样,每个结账的规模都有很大的不同。

$ b

当我 git checkout< revision> 时,它是否会将整个项目返回到当时的状态,或者它只是重新创建更改的文件如果您的工作树和 > staging区域是完全空的(当然除了 .git 子目录)并且运行

git checkout< revision>

那么您的工作树和临时区域将完美地反映出特定

  • 结帐没有问题,Git可以在没有打击的情况下执行eyelid:将特定修订版的内容复制到工作树中(如果需要,则覆盖已存在的内容)。或
  • 结账,如果执行结账,将导致本地变更的损失;因此,Git(假设您没有使用 -f 标志)会告诉您并中止结帐。或
  • 更复杂的情况可能出现在只有部分检出的东西中,并且一些本地未提交的更改会保留在您的工作树和/或索引中。关于这种情况的更多细节可以在我对为什么在检出不同的分支后依然存在未分离的更改?。
  • 每次结帐的大小相差很多。

    您是否考虑到未跟踪的文件?你提交了,然后删除大文件?根据您在问题中提供的信息,我们可以做的不过是推测尺寸差异很大的原因。

    Newb question, I want to make sure I understand this.

    When I git checkout <revision>, does this return the entire project to its state at that moment, or does it only recreate the files changed in that particular revision?

    For example: If my folder was completely empty besides the .git repo, and I git checkout master, will the resulting files be the project in its entirety, or only the files changed in the most recent commit?

    I ask, because I am checking out my project at various points (starting from the beginning), and instead of the project slowly growing in size as one would expect, the size of each checkout is varying quite a lot.

    解决方案

    When I git checkout <revision>, does this return the entire project to its state at that moment, or does it only recreate the files changed in that particular revision?

    If your working tree and staging area are completely empty (besides the .git subdirectory, of course) and you run

    git checkout <revision>

    then your working tree and staging area will perfectly reflect the contents of that particular revision.

    On the other hand, if your working tree is not empty when you run git checkout, what happens is much more subtle, and may be broken down into three cases:

  • The checkout is not problematic and Git carries it out without batting an eyelid: the contents of that particular revision get copied to your working tree (and overwrite stuff already present there, if needed). Or
  • The checkout, if it were carried out, would result in a loss of local changes; therefore, Git (under the assumption that you didn't use the -f flag) tells you off and aborts the checkout. Or
  • A more complicated situation may arise in which stuff is only partially checked out, and some local, uncommitted changes are kept in your working tree and/or index. More details about that situation can be found in my answer to Why are unstaged changes still present after checking out a different branch?.
  • [...] the size of each checkout is varying quite a lot.

    Are you taking into account untracked files? Did you commit, then later remove large files? On the basis of the information given in your question alone, we can do little more than hypothesize about the reason why the size varies a lot.

    更多推荐

    git checkout是否更新所有文件?

    本文发布于:2023-10-16 15:50:30,感谢您对本站的认可!
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文件   git   checkout

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!