欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

如何把本地项目上传到Github

程序员文章站 2022-03-07 12:44:54
...

1.首先登录  github  创建仓库,若无法忍受Github访问速度慢,参考 GIthub访问速度慢的解决方法

如何把本地项目上传到Github

如何把本地项目上传到Github

2.找到本地项目所在目录,右键 Git Bash Here

如何把本地项目上传到Github

3.Git Bash提交项目,分别执行以下命令

//1.使当前项目加入git管理
git init

//2.将项目全部内容添加到git(注意 .不能少)
git add .

//3.提交注释
git commit -m "first commit"

//4.连接上面创建好的github仓库(若要求输入用户名密码,按照提示输入)
git remote add origin https://github.com/xxx/xxx.git

//5.上传项目到Github
git push -u origin master

4.上传成功了,那么想把项目clone到本地环境怎么操作呢?

(1)选择workspace ,右键Git GUI, 选择Clone Existing Repository

如何把本地项目上传到Github

(2)或者右键Git Bash更简单,直接输入命令 git clone https://github.com/xxx/xxx.git

 

注意:

1.Git CMD 跟 Git Bash两者的区别:Bash是基于CMD的,Bash在CMD的基础上新增了一些命令和功能,故使用Bash更方便。

2.如果输入$ git remote add origin [email protected]:(github帐号名)/gitdemo(项目名).git 

    提示出错信息:fatal: remote origin already exists.

    解决办法如下:

    (1)、先输入$ git remote rm origin

    (2)、再输入$ git remote add origin [email protected]:(github帐号名)/gitdemo(项目名).git 就不会报错了!

3.egit push代码的时候报错,Can't connect to any repository:  cannot open git-receive-pack

   解决方式:打开eclipse安装目录下的eclipse.ini添加:-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2

   然后重启eclipse,再次push

 

相关标签: GitHub