We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第2079天 请问:使用git不小心把一个文件推送到了远程仓库,怎样删除远程仓库的该文件,本地还要用到这个文件
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered:
git rm --cached
这个命令会将文件从 Git 的追踪中移除,但保留该文件在本地。
git rm --cached <file_path>
例如:
git rm --cached path/to/your/file.txt
执行 git rm --cached 后,你需要提交这个更改。
git commit -m "Remove file from remote repository but keep it locally"
推送到远程仓库,以删除该文件:
git push origin <branch_name>
.gitignore
为了避免该文件再次被意外推送到远程仓库,建议将它添加到 .gitignore 文件中。
echo "path/to/your/file.txt" >> .gitignore git add .gitignore git commit -m "Add file to .gitignore" git push origin <branch_name>
这样,就成功地删除了远程仓库中的文件,但它仍然保留在本地,并且 Git 会忽略这个文件的进一步提交。
Sorry, something went wrong.
No branches or pull requests
第2079天 请问:使用git不小心把一个文件推送到了远程仓库,怎样删除远程仓库的该文件,本地还要用到这个文件
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered: