github 上传步骤

打开 https://github.com   直接在首页上注册   登陆



+New repository 创建一个新的仓库

github是服务端,要想在自己电脑上使用git我们还需要一个git客户端,

windows用户请下载 http://msysgit.github.com/

mac用户请下载 http://code.google.com/p/tortoisegit/

一路next,安装成功后,回到C盘,或任何文件夹下,点鼠标右键会多出一些菜单
Git Init HearGit BashGit Gui 说明安装成功。

1)在本地仓库里右键选择Git Init Here,会多出来一个.git文件夹,这就表示本地git创建成功。右键Git Bash进入git命令行

$ git init

2)在本地创建ssh key  (第二次上传就不需要创建)

$ ssh-keygen -t rsa -C "your_email@youremail.com"

后面的 your_email@youremail.com 改为你的邮箱。我的邮箱是garfunkel_@outlook.com , 也是在github上注册的那个邮箱



直接点回车,说明会在默认文件id_rsa上生成ssh key 

然后系统要求输入密码,直接按回车表示不设密码


重复密码时也是直接回车,之后提示你shh key已经生成成功。


然后我们进入提示的地址下查看ssh key文件。我的电脑的地址是C:\Users\garfunkel\.ssh ,其中garfunkel是我的电用户的名称

打开id_rsa.pub,复制里面的key。里面的key是一对看不懂的字符数字组合,不用管它,直接复制。

回到github网站,进入Account Settings,左边选择SSH KeysAdd SSH Key, title随便填,粘贴key。


3)验证是否成功,在git bash下输入

$ ssh -T git@github.com

回车就会看到: You’ve successfully authenticated, but GitHubdoes not provide shell access 。这就表示已成功连上github。

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

$ git config --globaluser.name "your name"

$ git config --globaluser.email "your_email@youremail.com"


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

$ git remote add origingit@github.com:yourName/yourRepo.git

后面的yourNameyourRepo表示你再github的用户名和刚才新建的仓库,加完之后进入.git,打开config,这里会多出一个remote “origin”内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。



上传:

1)接下来在本地仓库里添加一些文件,比如README

$ git add README   ($git  add -A)  ($git  add . )  

$ git commit -m "first commit"

2)上传到github 

$ git push origin master

git push命令会将本地仓库推送到远程服务器。

git pull命令则相反。

注:首次提交,先git pull下,修改完代码后,使用git status可以查看文件的差别,使用git add 添加要commit的文件。

若报错:

$git push origin master

Togithub.com:garfunke1/etcxm

 ! [rejected]        master -> master (non-fast-forward)

error:failed to push some refs to 'git@github.com:garfunke1/etcxm'

hint:Updates were rejected because the tip of your current branch is behind

hint:its remote counterpart. Integrate the remote changes (e.g.

hint:'git pull ...') before pushing again.

hint:See the 'Note about fast-forwards' in 'git push --help' for details.

 

Solve : $ git pull --rebaseorigin master


大功告成,现在你知道如何将本地的项目提交到github上了。

















  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值