github如何上传代码到仓库(github提交代码步骤)

上传文件到github

rw。hAo22.Com

正常来说:

1.先在自己的github上创建一个仓库并且需要配置好ssh公钥

在用户目录打开git 的bash,然后输入指令ssh-keygen -t rsa -C “youremail” 就会生成一个.ssh隐藏目录

然后里面两个文件 一个是id_rsa私钥 一个是id_rsa.pub公钥。

rw。hAo22.Com

将公钥添加到github上面,这里不多说了,之后按照常规操作来。

2.常规操作

rw。hAo22.Com
#这里是写一个字符串到README.md文件里(如果你创建的那个仓库没有点击初始化REAME.md的话,可以执行这个操作)
echo "# face-recognition" >> README.md
#初始化
git init
#添加自定义文件到暂存区
git add README.md
#提交
git commit -m "first commit"
#绑定远程仓库  就是你之前在github上创建的仓库地址
git remote add origin https://github.com/gkho/face-recognition.git
#推送到远程仓库
git push -u origin master

坑:

如果你初始化仓库的时候点击了Initialize this repository with a README那么需要先git pull

 git pull origin 
 #然后合并本地仓库再推送
 git merge origin master
 git push -u origin master
 
 

github解决大文件的上传

#设置缓存 这是500mb
git config http.postBuffer 524288000
# 1、安装git-lfs

git lfs install

# 2、跟踪一些文件,那么上传大小就会变少  比如可以跟踪py结尾的文件 git lfs track "*.py"
git lfs track "你要跟踪的大文件的拓展名"

# 3、push常规操作
git add  你要上传的大文件
git commit -m "add large file"
git push -u origin master

可能还是会错

使用git上传文件到github

那么输入

git config lfs.https://github.com/468336329Zc/face-recognition.git/info/lfs.                                                                                                                          locksverify false
#然后再次push
git push -u origin master