简体   繁体   English

Git更改为将提交的文件标记为已删除

[英]Git changes to be committed files marked as deleted

I am wanting to delete some old files on my repository due to some refactoring. 由于某些重构,我想删除存储库中的一些旧文件。 Git is saying my local repo is up-to-date. Git表示我的本地仓库是最新的。 However when I run git status I get the following: 但是,当我运行git status我得到以下信息:

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    app/foo1.php
#       deleted:    app/foo2.php
#       deleted:    app/foo3.php
#       deleted:    app/foo4.php
#       deleted:    app/foo5.php
#       deleted:    app/foo6.php

Prior to this I used git rm <file> to commit them. 在此之前,我使用git rm <file> commit它们。

  1. Why is this happening? 为什么会这样呢?
  2. Can I remove these deleted files for good? 我可以永久删除这些deleted文件吗? By this I mean when I run git status it shows Everything up-to-date 我的意思是,当我运行git status它将显示Everything up-to-date

` `

By using git rm you actually deleted the files, but you still have to apply your changes to the local and the remote repositories. 通过使用git rm您实际上删除了文件,但是仍然必须将更改应用于本地和远程存储库。

To do so, use the following commands: 为此,请使用以下命令:

git commit -m "clean up"
git push origin master

The first one commits your changes on your local repository and make them available for the next push to the remote repository. 第一个将您的更改提交到本地存储库,并使它们可用于下次推送到远程存储库。 The second command actually delivers the changes. 第二个命令实际上传递更改。

Of course, feel free to personalize the message for the commit. 当然,请随时个性化提交的消息。 Moreover, I'm assuming that you are working on the master branch, if it's not set it correctly to the proper one. 而且,我假设您正在master分支上,如果未正确将其设置为正确的分支。

You need to git commit after using git rm . 您需要在使用git rm后进行git rm git commit The git rm {filename} command only removes the files in the working tree, but you need to commit this change in order to commit the deletion into history. git rm {filename}命令仅删除工作树中的文件,但是您需要提交此更改才能将删除提交到历史记录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM