1.如果没有本地仓库,先初始化仓库:(不确定需不需要)
git init
2. 关联远程仓库(如果存在本地仓库,并与远程仓库关联,则跳过)
git remote add origin git@github.com:99Young99/Machine-learning.git (远程仓库地址)
3. 安装 git lfs
(一个仓库里面执行一次就好了)
git lfs install
4. 选择希望 Git LFS
管理的文件类型,或者直接指定文件
git lfs track "*.pdf" 或者 git lfs track "李航.pdf"
注: *.pdf
会搜索当下各文件中所有后缀为 pdf
的文件
如果想将整个文件夹通过通过 Git LFS 进行上传,可将整个文件夹打包为 .zip 文件,然后通过 git lfs track "*.zip"
5. 添加确定跟踪 .gitattributes
(配置文件,缺少它执行其他 git
操作可能会有问题,具体作用不详述)
git add .gitattributes
PS: 最终上传完毕后会在文件夹看到:
6. pull 操作拉取远程仓库的文件,与本地仓库合并
git pull --rebase origin master
7. 添加要上传(push)的文件(正常上传文件)
git add .
8. 提交到存储中
git commit -m “任意文字”
9. 上传到远程仓库
git push -u origin master
10. 注意事项
如果是 commit 提交过程中报错存在大文件,需要先撤销已提交的 commit
,再进行如上操作,如果是第一次 commit
就可以直接用。
# 撤销步骤
# 查看提交记录
$ git log
# 找到提交前的commit,重置
$ git reset xxxxx
如果是 git push 到 Gitee 上报错:LFS only supported repository in paid enterprise.
解决方法:
rm .git/hooks/pre-push
git push -u origin "master"
References
[2] error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.git