通过git lfs 将本地仓库上传到github 远端仓库

这篇博客介绍了如何使用Git Large File Storage (GitLFS) 将本地仓库上传到GitHub。首先确保已安装git和gitlfs,然后初始化项目文件夹,添加文件到暂存区,提交到本地仓库,并设置远程仓库。接着拉取远程主分支信息,将master分支重命名为main,最后推送到远程main分支。注意处理可能出现的GitHub登录超时问题。

通过git lfs 将本地仓库上传到github 远端仓库

仅常规使用方法(已经配置过 上传成功过)

前提:github 账号 git 安装 gitlfs安装

github可能会登录超时,可以改host或挂梯子。在上传前确保可以连接到GitHub,否则会报错。
git安装 gitlfs 安装可以csdn上找帖子 这里不说了。见最后的参考贴。

具体流程:

1.先进入你的存储文件(git 文件不要管 之后会生成的)
2.将要上传的文件放到文件夹中3
3.再右键开启bash界面。
在这里插入图片描述
bash界面
在这里插入图片描述
获取库地址
在这里插入图片描述

再在gitbash界面进行操作

git init // 1. 初始化项目文件夹 生成git文件

git add . // 2. 将当前文件下的所有文件加入暂存区  add . (之间有一个空格)

git commit -m "备注信息"// 3. 提交到本地仓库,备注信息在上传完成后会在github上显示

git remote add origin 你的库地址 // 4. 你的库地址在GitHub上获取 当然你要先在GitHub上建立一个库

git pull // 5. 拉取远程主分支信息,首次拉取合并信息 主要是想合并

git branch -m master main // 6. 把master 变为 main分支 GitHub上默认main分支 而本地默认master分支 

git push -u -f origin main  // 7. 提交到远程仓库,-f 是强制推送 主要为怕爆错

主要怕忘记 写给自己看到 勿喷 !

参考大佬帖子:

全流程
流程加修错
流程图

To push local files to a GitHub repository, you need to follow these steps using Git commands: 1. **Initialize a Git Repository**: If your project is not already under version control, navigate to your project directory and initialize a new Git repository. ```bash cd path/to/your/project git init ``` 2. **Add Files to the Repository**: You'll want to add all of your project's files to the Git repository. This can be done with the `git add` command followed by either a specific filename or `.` to add all files. ```bash git add . # Or for specific files git add filename.ext ``` 3. **Commit Your Changes**: Once you've added the files, commit them to the repository with a descriptive message. ```bash git commit -m "Initial commit" ``` 4. **Create a New Repository on GitHub**: Before pushing your code to GitHub, create an empty repository on GitHub. Do not check the option to initialize this repository with a README if prompted, as it will cause conflicts with your existing files. 5. **Link Local Repository to Remote Repository**: After creating the repository on GitHub, link your local repository to the remote one using the `git remote add` command. ```bash git remote add origin https://github.com/username/repository-name.git ``` 6. **Push to GitHub**: Finally, push your committed changes to the GitHub repository. For the initial push, you might use the `-u` (or `--set-upstream`) flag so that future pushes are simpler. ```bash git push -u origin master # Or if you're using main branch instead of master git push -u origin main ``` After the initial setup, you can simply use `git push` without any arguments to push changes to the same remote branch. For handling large files, consider using Git Large File Storage (LFS) or configure `.gitignore` to exclude unwanted large files from being tracked[^4]. If you have multiple repositories and wish to apply the same ignore rules, setting up a global `.gitignore` file could be beneficial[^2]. When working with submodules, which are separate projects within your project, you would add them using the `git submodule add` command followed by the URL of the submodule repository and the desired location within your project[^3]. Remember, after making any changes, always commit those changes before attempting to push to ensure they are included in the repository.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值