使用msysGit管理GitHub代码

  代码管理在日常开发中是非常重要的,现在主要使用的代码管理工具就有svn和git。今天就记录下怎么用msysGit管理GitHub上的代码。

一、在GitHub上注册账号,然后创建代码库

  1.进入GitHub网址:https://github.com注册即可

  2.创建代码库

     2.1进入github首页

     2.2点击右上角创建代码库

二、下载并安装msysGit客户端

  1.下载网址:https://git-for-windows.github.io/

  2.安装msysgit

三、使用msysGit连接GitHub

  1.打开刚安装的msysGit,点击"Git Bash.exe"


  2.为Github账户设置SSH key

  2.1产生ssh key

       输入命令:$ ssh-keygen -t rsa -C "你的邮箱地址"

       然后回车,接着输入密码,回车,再次输入密码,回车,就生成了ssh key

      产生的key默认在/c/Users/xxx/.ssh/目录下

      id_rsa.pub里面的内容即为ssh key,可用记事本打开。

  2.2负责ssh key到github上

      1.登录github

      2.点击右上方的settings图标


      3.选择 SSH key

      4.点击 Add SSH key

      5.填写名称和SSH key,最后提交,添加成功


  2.3测试连接github

     回到msysgit,输入命令:ssh -T git@github.com

     接着输入密码


四、使用msysGit管理代码库

  1.从github同步代码到本地

     从github页面中获取代码库地址

     同步成功


  2.提交代码到github


     2.1如果使用HTTPS:

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/guochy2012/test.git
git push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/guochy2012/test.git
git push -u origin master

       2.2如果采用SSH:

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:guochy2012/test.git
git push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:guochy2012/test.git
git push -u origin master

使用HTTPS需要每次输入密码,SSH则不用,但SSH需要配置密钥 。

提交代码都是先使用命令 git add XXX 添加该文件或者文件夹

然后使用命令 git commit -m "提交说明" 把该操作提交到代码库

最后使用git push 把本地的提交,提交到github上




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值