2019/02/25
上传到github的基础操作,以及遇到的小问题及解决方法。(以下以博主的一次上传为例)
基础操作:
- 进入到本地的要上传的文件目录下:
cd /E/BUPT/Postgraduate/BIG data/bigdata/bigdata_phrase3
- 在当前项目的目录中生成本地的git管理
git init
- 将项目上所有的文件添加到仓库中的意思,如果想添加某个特定的文件,只需把.换成相应文件
git add .
- 提交注释,相当于做个标记。
""
里面内容根据自己需要修改。
git commit -m “first commit”
- 将本地的仓库关联到github上
git remote add origin https://github.com/darcy-shimmer/bigdata_phrase3.git
- 把代码上传到github仓库
git push -u origin master
几个问题:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/darcy-shimmer/bigdata_phrase3.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
这个问题是因为本地库和远程库内容不统一,需要把远程库里面的内容放到本地:
git pull origin master
(实在不行,就:git pull --rebase origin master)
然后再
git push -u origin master
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 5f2b1afe371384f955857faa1f5d0c57
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File hive-kudu-mysql/phrase3/newdata_customer/customer is 271.25 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/darcy-shimmer/bigdata_phrase3.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/darcy-shimmer/bigdata_phrase3.git'
上传文件过大。详见 https://help.github.com/en/articles/working-with-large-files 。
比较直接的方法:
git rm --cached hive-kudu-mysql/phrase3/newdata_customer/customer
git commit --amend -chead
然后
git push -u origin master
当然你也可以通过git reset [版本号]
返回到添加前的某个版本号,本地删除大文件,再重新进行之后的操作。