git 将本地项目提交到github

将项目传到githut

首先进入到项目根目录

Git Bash here

 

首先在本地创建ssh key;

$ ssh-keygen -t rsa -C "[email protected]"

后面的[email protected]改为你的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key

为了验证是否成功,在git bash下输入:

  $ ssh -T [email protected]

接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。

  $ git config --global user.name "your name"

  $ git config --global user.name "your name"$ git config --global user.email "[email protected]"

 

your name   名字可以随意起

 

进入要上传的仓库,右键git bash,添加远程地址:

  $ git remote add origin [email protected]:guozhijie87/stock.git

 

 

接下来就是上传了

$ git add README

$ git commit -m "first commit"

$ git push origin master

 

上传全部的文件 

$ git add -A

 

猜你喜欢

转载自guozhijie87.iteye.com/blog/2388687