将所有删除的文件添加到带有git的提交
我已经对分支机构进行了一轮更改,并有10个修改后的文件和10个文件。
如果我运行git add。
这只会将修改的文件添加到我的提交中。我想从远程存储库中删除已删除的文件,并添加我的修改后的文件。
我可以使用git rm fileName
,但是由于我有很多文件可以删除,所以我想知道是否有一种“全部”的方法。
我谷歌搜索并找到了git rm -r *
,但这似乎不起作用。
有没有命令可以让我这样做?
I have made a round of changes to a branch and have 10 modified files and 10 files I have deleted.
If I run git add .
this will only add the modified files to my commit. I want to remove the deleted files from the remote repo as well as add my modified files.
I can use git rm filename
, but since I have so many files to remove I was wondering if there was a way to do an 'all'.
I Googled and found git rm -r *
but this doesn't seem to work.
Is there a command that will allow me to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您想进行所有更改和删除的文件并单行提交:
请注意,该命令不会添加新文件,因为GIT是关于跟踪更改的。它依靠您告诉它哪些文件足够重要,可以跟踪。
如果您有一些或只想在提交之前进行更改,则必须手动添加文件或使用通配符:
git git add -a
stage ast as all(包括新文件,修改和删除)git add。
阶段新的和修改,没有删除git add -u
阶段修改和删除,而没有新的commit:
If you want to stage all your changed and deleted files and commit in one-line:
Note that this command won't add new files as Git is about tracking changes. It relies on you to tell it which files are important enough to track.
If you have some or you just want to stage the changes before you commit, you will have to add your files manually or use wildcard:
git add -A
stages All (include new files, modified and deleted)git add .
stages new and modified, without deletedgit add -u
stages modified and deleted, without newthen commit:
尝试以下操作:
git add -u
为包括已删除/更新文件在内的所有更改。然后只需运行
git commit -m'您的提交消息'
进行提交即可。Try this:
git add -u
to stage all your changes including deleted/updated files.Then just run
git commit -m 'your commit message'
to commit.使用Interactive git add,它允许交互方式选择文件:
git add -i
。2
(更新部分)。1-10
。https://git-scm.com/book/book/en/v2 /git-tools-interactive阶段
Use interactive git add, it allows to select files interactively:
git add -i
.2
(update section).1-10
.https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging
可以使用标准外壳工具。在这种情况下> ripgrep )。
建议的命令是:
如果您知道每个工具,则命令大多是自我解释的。如果您不这样做,请学习它们,它们很有用。简而言之:GREP找到具有指定状态的行。 “删除”。尴尬过滤第二列。 Xargs将其转换为参数格式。
为此/这些管道制造一个别名使它成为一项琐碎的任务。
It is possible to utilize standard shell tools. In this case
grep
,xargs
andawk
(or their newer/faster/different alternatives likenawk
orripgrep
).The suggested command is:
The command is mostly self-explonatory if you know each tool. If you dont, learn them, they are usefull. In short: grep finds lines with specified status eg. "deleted". awk filters second column. xargs transforms it to argument format.
Making an alias for this/these pipeline makes it a trivial task.
git rm -r *
您需要提交文件并推动后,您将看到可以帮助您的更改希望:)
After the
git rm -r *
you need to commit your file and push and you gonna see the changeHope that can help you :)
要将删除的文件添加到git索引,请运行
To add removed files to the the git index, run
要影响远程服务器中的更改,您需要在
push
从远程服务器上进行更改。git add。
要跟踪所有更改git commit -m“您的消息”
cistiongit push push oincor [your -branch]
以将更改推到 现在,您的远程存储库通过
ssh
'将这些更改拉到您的远程服务器上,然后导航到项目路径,然后将文件从远程服务器中删除
To affect the changes in remote server you need to both
push
changes from your local machine andpull
from remote server.git add .
to track all changesgit commit -m "your message"
to commitgit push origin [your-branch]
to push changes to your remote repoNow pull those changes to your remote server by
ssh
'ing to it and navigating to project path and doThen the files would be deleted from your remote server