使用点的Git结帐 [英] Git checkout with dot

查看:103
本文介绍了使用点的Git结帐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下一个 git 命令有何区别:

  git checkout分支
git checkout分支。
git checkout。 #< - 用于分支

为什么当我用不同的分支结账到第一个我错过了一些文件。

但是当我使用第二个命令时,一切正常?

解决方案

< a href =http://git-scm.com/docs/git-checkout.html =noreferrer> git checkout (1)


  1. 仅限于分支说明符 git checkout branch )它会将当前工作目录切换到指定分支,保留本地更改,否则失败。如果你已经在分支上,它将不会执行任何操作。它只修改 HEAD 分支之间不同的工作目录中的文件,如果它们中的任何一个进行了本地修改,则会失败索引或不)。
  2. 使用路径说明符,它将覆盖所有匹配的文件(所有文件匹配)与指定内容:


    1. 仅限路径说明符 git checkout。)它从索引写入内容。这是取消未分配本地修改。要撤销分阶段修改,请使用 git reset 和路径说明符。 使用分支和路径说明符 git checkout分支。)它在指定的版本中写入内容。它不会修改 HEAD 点的位置,所以如果分支不同于 HEAD ,之后会有未分离的更改。




    2. 请注意,手册页区分了使用-b / - 分支选项和-p / - 补丁选项,但这些大多是上述情况的直接扩展。


      What difference between next git commands:

      git  checkout branch
      git  checkout branch .
      git  checkout  .  #<-- used at the branch
      

      Why when I checkout different branches into different folders with first one I missed some files.
      But when I am using second command, everything is ok?

      解决方案

      git checkout(1) does very different things whether given path specifier or not.

      1. With branch specifier only (git checkout branch) it will switch current working directory to specified branch, keeping local changes if possible and failing otherwise. If you already are on branch, it will do nothing at all. It only modifies files in the working directory that differ between HEAD and branch and fails if any of them has local modifications (indexed or not).
      2. With path specifier it will overwrite the all matching files (all files match .) with specified content:

        1. With path specifier only (git checkout .) it writes content from index. That it is undoes unstaged local modification. To undo staged modifications, use git reset with path specifier.
        2. With both branch and path specifiers (git checkout branch .) it writes content in specified revision. It will not modify where HEAD points, so if branch is different from HEAD, there will be unstaged changes afterwards.

      Note, that the man page distinguishes additional cases for use of the -b/--branch option and -p/--patch option, but those are mostly straightforward extensions of the above cases.

      这篇关于使用点的Git结帐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆