> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/centos/git-jiao-cheng/git-da-wen-jian-shang-chuan.md).

# Git 大文件上传

主要针对超过100M大文件上传

## Git 大文件上传

* 前提是已经做了 SSH 免密(略，自行百度)

```bash
yum install git-lfs git


git config --global user.name "you git name"
git config --global user.email "yougit@email.com"



git clone git@github.com:dookjer/1.git

cd 1

上传 openjdk-11+28_linux-x64_bin.tar11.gz 大文件 到 1 目录下

```

## 上传到默认分支

```bash
##  安装大文件上传应用
git lfs install

## 追踪要上传的大文件，*表示路径下的所有文件
git lfs track *


## 添加先上传的属性文件(要先上传属性文件，不然有可能失败)
git add .gitattributes 


## 添加备注说明
git commit -m "Git LFS commit" 


## 建立本地和 Github 仓库的链接
git remote add origin git@github.com:dookjer/1.git


## 上传属性文件， 默认是 main
git push origin main


## 添加要上传的大文件，*表示路径下的所有文件
git add * 

## 添加大文件上传的说明
git commit -m "Git LFS commit" 

## 上传大文件
git push origin master

```

## 切换分支上传

```bash
git clone git@github.com:dookjer/1.git
cd 1

# 移动大文件到当前,并切换到 v2 分支上传

git add .
git commit -m "v2"
git branch -M v2
git push origin v2
```

## 切换回主分支

```bash
[root@localhost 1]# git status
# On branch v3
# Your branch is ahead of 'origin/main' by 1 commit.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean


[root@localhost 1]# git branch -a
  main
* v3
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
  remotes/origin/v2
  remotes/origin/v3
[root@localhost 1]# git checkout main
Switched to branch 'main'


[root@localhost 1]# git status
# On branch main
nothing to commit, working directory clean
```
