为什么结帐有时会创建一个文件? [英] Why does checkout sometimes stage a file?

查看:157
本文介绍了为什么结帐有时会创建一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次开始使用Git时,我发现 checkout 命令很混乱。但是,当我适应Git的版本控制模型时,它开始有意义。现在我不得不将Git教给我的同事,而我试图简单地解释 checkout 。我认为我有一个简单的解释(来自文档):

When I first started using Git, I found the checkout command quite confusing. However, as I adapted to Git's model of version control, it started to make sense. Now I am having to teach Git to my coworkers, and I'm trying to explain checkout simply. I thought I had a simple explanation (from the documentation):


签出一个或多个工作树的路径

Checkout a branch or paths to the working tree

统一一些您可以使用checkout进行的操作,这些操作看起来像是一个新的Git操作系统:

That seems to unify some of the things you can do with checkout which seem like a diverse set of operations to someone new to Git:

git checkout .
git checkout HEAD .
git checkout HEAD~2
git checkout feature/update-readme README.md

...除了最后一个,因为它不会更新工作目录,它会对文件进行分级。

...except for the last one, because that doesn't just update the working directory, it stages the file.

如何理解结帐的原因或结算时间out会导致有东西上演,而不是只复制到工作目录中?

How can I understand why or when checkout out will result in having something staged instead of just copied into the working directory?

推荐答案

git checkout 实际上总是将所有文件都检出。但是如果你没有指定路径(如前三个例子),你的HEAD也将被设置为你签出的提交,因此你的阶段与你的HEAD相同,即没有改变提交。

git checkout does in fact always stage all the files checked out. But if you do not specify a path (as in your first three examples), your HEAD will also be set to the commit you checked out and therefore your stage is identical to your HEAD i.e. there are no changes to commit.

这篇关于为什么结帐有时会创建一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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