Github_简单使用

!!!!终端使用不要使用git clean - d -fx
会删除所有代码及代码所在的目录

参考链接:
http://backlogtool.com/git-guide/cn/intro/intro1_1.html
准备工作:
下载安装git客户端 http://code.google.com/p/git-osx-installer/downloads/list?can=3
注册github账号 https://github.com/ –>Pricing and Signup –>Create a free account
创建ssh:
在local打开terminal:
cd/.sshsshsshsshssh ssh-keygen -t rsa -C xxxxx@gmail.com(注册github时的email)
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/twer/.ssh/id_rsa):
Created directory ‘/Users/twer/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/twer/.ssh/id_rsa.
Your public key has been saved in /Users/twer/.ssh/id_rsa.pub.
The key fingerprint is:
18:16:11:c9:01:6c:48:09:7f:27:c6:43:0d:7f:3f:84 xxxxx@gmail.com

   如果要修改ssh生成目录,在蓝色位置处输入要生成的路径,选择默认的话,会生成在 ~/.ssh下

在github中添加ssh:
登陆github,选择Account Settings–>SSH Public Keys 添加ssh
Title:xxxxx@gmail.com
Key:打开你生成的id_rsa.pub文件,将其中内容拷贝至此
测试SSH:
sshgit@github.comTheauthenticityofhostgithub.com(207.97.227.239)cantbeestablished.RSAkeyfingerprintis16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Areyousureyouwanttocontinueconnecting(yes/no)?yesWarning:Permanentlyaddedgithub.com,207.97.227.239(RSA)tothelistofknownhosts.PTYallocationrequestfailedonchannel0Hixianfuying!Youvesuccessfullyauthenticated,butGitHubdoesnotprovideshellaccess.Connectiontogithub.comclosed.yesgit git config –global user.name “your real name”
$git config –global user.email “xxxxx@gmail.com”

至此,git和github的设置就完成了,下面就是如何将本地代码push到github上,以及如何从github上pull代码了:
在github中创建Repository:
https://github.com/ –> New Repository 输入Repository信息 projectName
在本地创建代码库:
创建一个文件夹作为local repository
mkdirtest cd test
vitest.txtlocalrepository git add test.txt
初始化local repository
gitinitcommit git commit -a
定义远程服务器别名
gitremoteaddaliasgit@github.com:xxxxx/projectName.gitpushgithub git push alias master
这样就可以将本地的代码push到github的repository中了

从github中pull代码:
在github中搜到你想要pull的代码,如https://github.com/edgecase/ruby_koans
选择fork,将此repository fock到你的repository下
在本地创建local repository并初始化
使用命令:
$git pull git@github.com:xxxxx/ruby_koans.git
将github上的代码pull到local repository中

参考:
http://apps.hi.baidu.com/share/detail/16068052
http://blog.csdn.net/banxi1988/article/details/6555293
http://apps.hi.baidu.com/share/detail/31697631

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值