项目不会管理?今天,他来了(如何将本地项目上传到github进行管理)


想必大多的开发者都会用到github开源库,里面咱们能够找到各类大神开源的项目,不须要咱们本身再造轮子,站在前人的肩膀上看世界就是爽。咱们虽然不是大神,可是咱们也能够把本身的项目开源道github上作一点点贡献。经过本篇文章的学习,你讲学会将本地项目上传到github,经过如下步骤:
1.git的安装
2.注册github账号和建立仓库
3.git操做

一.git安装

windows上安装git:https://git-for-windows.github.io/,直接一路next就行。安装完了随便找一个地方单击右键出现Git Gui Here和Git Bash Here选项就能够了。css

二.建立github账号和仓库

1.到github官网https://github.com/注册本身的账号
2.点击new建立本身的仓库:
在这里插入图片描述
在这里插入图片描述
建立对应的信息:
Repository name: 仓库名称
Description(可选): 仓库描述介绍
Public, Private : 仓库权限(公开共享,私有或指定合做者)
Initialize this repository with a README: 添加一个README.md
点击Create repository建立仓库完成:html

在这里插入图片描述
咱们点击Clone or download弹出一个Clone with HTTPS的框,复制里面的连接。java

三.git操做

1.咱们在本地找到咱们项目的位置,单击右键选择Git Bash Here弹出以下框:
在这里插入图片描述
2.输入git clone +咱们上一步复制的链接按回车,把github上面的仓库克隆到本地。在你的本地项目下就会多一个文件夹出来,将项目中的其余文件所有拷贝一份到该目录下:
在这里插入图片描述
拷进本身要上传的项目:
在这里插入图片描述
3.输入cd +出现的目录进入到该目录下,好比这里cd qiyeweixinsecond,其实输入qi按tab键会自动补全,这个Git操做基本上是linux操做
在这里插入图片描述
4.4.输入git add .按回车将qiyeweixinsecond目录下的文件都添加进来,注意add和.须要隔开
在这里插入图片描述
5.输入git commit -m "第一次提交"按回车来添加提交信息,在这里须要根据提示添加本地git用户的邮箱和名称
git config --global user.email “XXXXXX@qq.com”
git config --global user.name “XXXXX”
6.输入git remote add orgin +咱们建立仓库复制的链接进行和仓库远程链接
7.输入git push -u orgin master 这个操做是将本地项目push到仓库,这里会要求用户输入github的帐号和密码
在这里插入图片描述python

四.容易出的错误:

1.Git Fatal:The remote end hung up unexpectedlylinux

问题描述:Git在推送项目时报错:fatal: The remote end hung up unexpectedly。git

问题缘由:推送的文件太大。程序员

解决方法:github

1.修改设置git config文件的postBuffer的大小。(设置为500MB)web

在这里插入图片描述
增长下图所示的两行内容windows

[http]
    postBuffer = 524288000

在这里插入图片描述

或者命令:

git config --global http.postBuffer 524288000

注:–local选项指定这个设置只对当前仓库生效。

2.或者直接修改本地仓库的.config文件。
①打开项目所在的目录

②设置显示隐藏文件
在这里插入图片描述
③编辑config文件
在这里插入图片描述
增长下图所示的两行内容

[http]
    postBuffer = 524288000

在这里插入图片描述

2.git将本地内容传送到远程仓库出现![rejected] master -> master (fetch first)错误

问题:使用git push -u 远程库名 master 命令将本地提交的内容传到git远程库时出现错误:
命令: git push -u origin master

出现错误:
  To https://github.com/imjinghun/university.git
  ! [rejected] master -> master (fetch first)
  error: failed to push some refs to ‘https://github.com/imjinghun/university.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 push -f 命令从新传一遍就能够成功了
命令:git push -f

结果:
  Counting objects: 5739, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (5341/5341), done.
  Writing objects: 100% (5739/5739), 205.84 MiB | 40.00 KiB/s, done.
  Total 5739 (delta 1847), reused 0 (delta 0)
  remote: Resolving deltas: 100% (1847/1847), done.
  remote: warning: GH001: Large files detected. You may want to try Git Large File
  Storage - https://git-lfs.github.com.
  remote: warning: See http://git.io/iEPt8g for more information.
  remote: warning: File ed5d681ab7d6af5905bcbae56de9ee0477d9ef3b is 60.34 MB;
  this is larger than GitHub’s recommended maximum file size of 50.00 MB
  To https://github.com/imjinghun/university.git
  + cd5b93f…83b3d6c master -> master (forced update) 在这里插入图片描述

五.如何修改github上仓库的项目的语言类型

问题:
在把项目上传到github仓库上时语言会显示错误语言
好比我刚写的python程序显示的语言是html

原理:
github 是采用 Linguist来自动识别你的代码判断归为哪一类

解决办法:
咱们在仓库的根目录下添加.gitattributes文件:并写入 注意 . 不能少.

*.js linguist-language=python
   *.css linguist-language=python
   *.html linguist-language=python

意思是将.js、css、html看成java语言来统计

在这里插入图片描述
显示效果:
在这里插入图片描述

这是我出现的一些问题
能够看到,最后Counting objects:100%,done表示咱们已经上传成功,而后刷新咱们的仓库就有了。
在这里插入图片描述
在这里插入图片描述
全部巧合的是要么是上天注定要么是一我的偷偷的在努力。

我的微信公众号,专一于学习资源、笔记分享,欢迎关注。咱们一块儿成长,一块儿学习。一直纯真着,善良着,温情地热爱生活,,若是以为有点用的话,请不要吝啬你手中点赞的权力,谢谢我亲爱的读者朋友
五角钱的程序员,专一于学习资源、笔记分享。
Desire is the starting point of all achievement, not a hope, not a wish, but a keen pulsating desire which transcends everything.

渴望是全部成就的原点,不是但愿、不是愿望,而是一个热切、使人悸动、凌驾一切的渴望。

2020年4月4日于重庆城口 好好学习,每天向上,终有所获