git提交跳过csv文件

jw5wzhpr  于 2022-12-02  发布在  Git
关注(0)|答案(1)|浏览(174)

我的存储库包含多种文件类型,包括.csv。当我依次执行git add .git status时,我看到:

git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    modified:   .ipynb_checkpoints/dpm-checkpoint.ipynb
    new file:   .ipynb_checkpoints/dp-checkpoint.ipynb
    modified:   App Data/dfr.csv

csv文件太大,被git拒绝。

git push origin master
Enumerating objects: 852, done.
Counting objects: 100% (852/852), done.
Delta compression using up to 8 threads
Compressing objects: 100% (839/839), done.
Writing objects: 100% (842/842), 373.87 MiB | 7.10 MiB/s, done.
Total 842 (delta 26), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (26/26), completed with 5 local objects.
remote: warning: File App Data/dfr.csv is 95.38 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/ks/SP.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/ks/SP.git'

我如何使用git压缩csv文件,然后推送它们,或者完全跳过csv文件类型?

bq3bfh9z

bq3bfh9z1#

通常,我们不会把文件数据放在github上。
在你的例子中,首先,你可以使用.gitignore(一个文件)来排除那些我们不想让git跟踪的文件(这里是数据文件)
第二个原因是,您将文件数据添加到staging are,因此必须通过命令将其从staging are/index/cached中删除

git rm --cached <path-to-file>

然后,放入上面刚创建.gitignore文件
最后

git add .
git push origin master

相关问题