[英]How to exclude binary file from remote git repo?
I commited and pushed binary file to git repo.我将二进制文件提交并推送到 git 存储库。 Actually I don't wan't this file in git repo, I was needed to add it to LFS.
实际上,我不希望 git 存储库中的这个文件,我需要将它添加到 LFS。
So, firstly question is - how to exclude this file from remote git tracking?所以,第一个问题是 - 如何从远程 git 跟踪中排除这个文件?
Add it to your .gitignore
file and don't forget to commit the file:-)将其添加到您的
.gitignore
文件中,并且不要忘记提交该文件:-)
.gitignore
for you and add the required path to your binary files/folder(s).gitignore
并将所需的路径添加到您的二进制文件/文件夹Once you added the file to .gitignore
you can remove the "old" binary file with BFG.将文件添加到
.gitignore
后,您可以使用 BFG 删除“旧”二进制文件。
Since the file is already tracked by git, unless you will remove it from history (ex. BFG) you need to remove it manually and commit your changes.由于该文件已被 git 跟踪,除非您将其从历史记录中删除(例如 BFG),否则您需要手动将其删除并提交更改。
How to remove big files from the repository
You can use git filter-branch
or BFG.您可以使用
git filter-branch
或 BFG。 https://rtyley.github.io/bfg-repo-cleaner/ https://rtyley.github.io/bfg-repo-cleaner/
BFG Repo-Cleaner
an alternative to git-filter-branch.
git-filter-branch 的替代方案。
The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:
BFG 是 git-filter-branch 的更简单、更快的替代方案,用于从 Git 存储库历史记录中清除不良数据:
* Removing Crazy Big Files*
*删除疯狂的大文件*
* Removing Passwords, Credentials & other Private data* 删除密码、凭证和其他私人数据
In all these examples bfg is an alias for java -jar bfg.jar.
在所有这些示例中,bfg 是 java -jar bfg.jar 的别名。
# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa} my-repo.git
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.