GitHub上传项目

主题:向git上传本地项目


step1:

https://github.com/上注册一个账号

step2:

(一):先在git上创建好项目文件夹

(二):git上传项目有两种方式:


1)https在上传的时候需要输入用户名和密码,ssh不用

2)用ssh key上传需要把ssh key配到github上,用当前账号邮箱生成的SSH KEY

(三):接下来就是上传了,

上传时也分两种:

1)不是git管理的项目(svn管理)

先通过命令git init把这个文件夹变成Git可管理的仓库

//进入要上传项目的文件夹

git init

git add .(.代表上add所有)

git commit -m "first commit"

git remote add origin https://github.com/yangshujinggirl/com.ltn.static.git git push -u origin master

git push -u origin master

2)*git管理的项目:

(1)在gitLab上面配上ssh key(和github上一样的),否则没有权限从gitLab上拉代码。

git add .(.代表上add所有)

git commit -m "first commit"

git remote add origin https://github.com/yangshujinggirl/com.ltn.static.git

git push -u origin mastergit push -u origin master

在上传过程中可能会出现如下问题:

Q1:

//输入

$ git remote add origin  git@github.com:yangshujinggirl/com.ltn.static.git

///出错信息:

fatal: remote origin already exists.

解决办法如下:

///先输入

$ git remote rm origin

///再输入

$ git remote add origin git@github.com:djqiang/gitdemo.git 

Q2:

////输入

$ git remote rm origin 

///出错信息:

Could not remove config section 'remote.origin'. 

解决方案:

修改gitconfig文件的内容

1)找到你的github的安装路径,例:                                                  C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd          96720bb5c8\etc

2)找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!


Q3:

//输入

$ ssh -T git@github.com

///出错信息:

Permission denied (publickey).因为新生成的key不能加入ssh就会导致连接不上github。

解决方案:

////先输入

$ ssh-agent

////再输入

$ ssh-add ~/.ssh/id_key


 如果还是不行的话,

////输入

ssh-add ~/.ssh/id_key

///出错信息:

Could not open a connection to your authentication agent.

解决方案:

key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。

最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。

 Q4:

////输入

$ git push origin master

////出错信息:

error:failed to push som refs to .......

解决方案:

 ///先输入

$ git pull origin master //先把远程服务器github上面的文件拉下来

///再输入

$ git push origin master

如果出现报错

fatal: Couldn't find remote ref master    或者

fatal: 'origin' does not appear to be a git repository   以及

fatal: Could not read from remote repository.

则需要重新输入$ git remote add origin git@github.com:djqiang/gitdemo.git

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 工具:git工具(官网下载: https://git-scm.com/downloads) 正常安装git,一路默...
    造梦先生2mr阅读 2,565评论 0 3
  • 今天闲来无事搞整一下github上传项目,中间还是有些波折,参考了一下几位网友的综合一下: CKTim——http...
    BulletYuan阅读 364评论 0 0
  • 说到GitHub相信大家都不陌生,这里就不再赘述了。作为开源代码库以及版本控制系统,使用好了会非常受益。经常维护自...
    辰星撒欢的蒜苗阅读 792评论 0 2
  • 月觉得自己是个不一般的人。从小就觉得自己应当是神仙,隐藏在人间。 她听人说小时候算命先生说她将来读书会很厉害。 果...
    灵剑阅读 181评论 8 0
  • 阅读:《演讲口才》乐嘉 感悟:别副一个鸭梨变成苹果 写作:云里雾里 幸福感:5分。 出差去太白,早上起床后和同事一...
    一笑而过2023阅读 381评论 1 1