简体   繁体   English

如何重命名/删除 git 存储库中的文件?

[英]How can i rename / delete files in git repository?

I created a git repository projecteuler-solutions and then i wanted to remove the word Euler from the file names so i renamed the files to just numbers and added the renamed files using an add command and then commited and pushed the changes, but even though in the status the file names with a euler prefix were marked as D they didn't get deleted, how can i delete those files now and what is the usual flow to rename the files?我创建了一个 git 存储库projecteuler-solutions然后我想从文件名中删除单词 Euler 所以我将文件重命名为数字并使用添加命令添加重命名的文件然后提交并推送更改,但即使在带有欧拉前缀的文件名的状态被标记为 D 他们没有被删除,我现在如何删除这些文件以及重命名文件的通常流程是什么?

Removal: git rm拆卸: git rm
Renaming: git mv更名: git mv

You can delete those files by using git rm :您可以使用git rm删除这些文件:

git rm euler10.py

Normally you would use git mv to rename/move files:通常你会使用git mv来重命名/移动文件:

git mv oldfilename newfilename

Go ahead and rename in whatever way you are used to in your file system. Go 提前并以您在文件系统中习惯的任何方式重命名。 Now you need to add all the changes.现在您需要添加所有更改。 your rename is seen as a delete and an add.您的重命名被视为删除和添加。

git add -A

will be shown as a move.将显示为移动。 You can see this by running您可以通过运行看到这一点

git status

This workflow will allow you to not worry about git commands and concentrate on your work.此工作流程将使您不必担心 git 命令并专注于您的工作。

hope this helps.希望这可以帮助。

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

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