英文:
What is the git command for the action to be considered at the remote repository after I deleted a tracked file?
问题
有一个已跟踪的文件,我们不再需要它了。我已经在我的本地仓库中删除了这个文件。所以在远程仓库上生效此操作的git
命令是什么?
英文:
There is a tracked file that we do not need anymore. I deleted the file on my local repository. So what are the git
commands to write in order for the action to be effective on the remote repository ?
答案1
得分: 1
取消跟踪文件
如果你不希望 git
跟踪某个文件,你可以使用以下命令取消跟踪:
git rm --cached 文件名
然后你需要本地提交这些更改:
git commit
之后,你可以将更改推送到远程仓库:
git push
删除文件
如果你想删除一个文件,只需将它从仓库中移除。
使用以下命令添加更改:
git add -A
你可以使用 git status
检查更改:
在分支 main 上
你的分支与 'origin/main' 一致。
要提交的更改:
(使用 "git restore --staged <文件>..." 来取消暂存)
删除: file.md
然后,你可以提交你的更改:
git commit -m "删除了文件"
将更改推送到远程仓库:
git push
英文:
Untrack the file
If you don't want git
to track a file you have to can untrack it with
git rm --cached filename
Then you will need to commit the changes locally with:
git commit
After that you can push the changes to the remote with:
git push
Delete the file
If you want to delete a file, simply remove it from the repo.
Add the changes with:
git add -A
You can check the changes with git status
:
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: file.md
Then you can commit your changes with:
git commit -m "Removed the file"
To push the changes on the remote:
git push
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论