在不使用rm的情况下重命名文件 [英] Renaming a file without using rm in git

查看:117
本文介绍了在不使用rm的情况下重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用git,特别是添加和删除文件的艺术。以下是我所做的:


  • 将文件添加到我的工作目录中

  • 使用 git add 将文件添加到回购站

  • 已提交

  • 更改了文件名

  • 使用 git add 将新文件添加到回购站

  • 已提交

  • 使用 git checkout head



此时,我期望在我的目录中看到两个文件,因为我没有使用 rm 来摆脱原始文件名。但是,我发现只有我的文件夹中重命名的文件。为什么是这样?是 rm 会自动应用还是还有其他内容?

编辑========= =======================



看起来最后一个结帐头让我陷入了'脱离头部'状态。



我做了以下操作:


  • 进行了额外的提交

  • git checkout master



现在我看到两个文件。为什么 git checkout master 会显示两个文件的存在,但是 git checkout head 没有?

解决方案

git跟踪内容而不是文件。这就是为什么通过操作系统命令进行重命名也与通过git进行重命名相同的原因。 http://gitimmersion.com/lab_20.html


I am learning how to use git, especially to art of adding and removing files. Here is what I have done:

  • added a file to my working directory
  • used git add to add the file to the repo
  • committed
  • changed the name of the file
  • used git add to add the new file to the repo
  • committed
  • used git checkout head

At this point, I expected to see two files in my directory because I did not use rm to get rid of the original file name. However, I found only the renamed file in my folder. Why is this? Was rm automatically applied or is there something else going on?

EDIT ================================

It looks like that last checkout head put me into a 'detached head' state.

I did the following:

  • made and additional commit
  • git checkout master

Now I see two files. Why would git checkout master reveal the presence of both files, but git checkout head did not?

解决方案

git tracks the content and not files. That is why a rename via the operating system commands also works the same way as a rename via git. http://gitimmersion.com/lab_20.html

这篇关于在不使用rm的情况下重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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