美文网首页
GitHub简单使用

GitHub简单使用

作者: _Choice_ | 来源:发表于2017-07-04 11:38 被阅读15次

    很多开发者想开源自己的代码或者demo,开源到Github是个不错的选择,那么如何上传我们的代码到Github,令所有人可以下载使用呢?这里我们的目的很明确,就是上传我们本地电脑里面的一份代码到Github

    第一步、申请Github账号。https://github.com/ ,如果已经有Github账号,那么直接进入第二步。
    第二步、配置Github的ssh key。
    1.设置git的user name和email: git config –global user.name “zhengwenming”(注意⚠:global后面是两个 -哦,不是一个-哦) git config –global user.email88888888@qq.com” 2.查看是否已经有了ssh密钥:cd ~/.ssh 如果没有密钥则不会有此文件夹,有则备份删除 3.保存密钥: ssh-keygen -t rsa -C “XXXXXX@qq.com” 按3个回车,密码为空。
    Your identification has been saved in /home/tekkub/.ssh/id_rsa. Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub. The key fingerprint is: ………………
    最后得到了两个文件:id_rsa和id_rsa.pub 4.添加密钥到ssh:ssh-add 文件名 需要之前输入密码。 5.在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。 打开https://github.com/ ,登陆,然后添加ssh(到Account setting,账户设置里面有添加ssh key的入口)。
    6.测试:ssh git@github.com The authenticity of host ‘github.com (207.97.227.239)’ can’t be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘github.com,207.97.227.239′ (RSA) to the list of known hosts. ERROR: Hi tekkub! You’ve successfully authenticated, but GitHub does not provide shell access Connection to github.com closed.
    第三步、登录Github,创建仓库。
    点击主页右下方的“+ New repositories”。意思是在Github上面建立一个仓库。然后要填写仓库的信息了,repository name是仓库的名字,这个用英文,最好这个名字能反映这个项目的作用(这个可以以后修改的);Description填写仓库里面项目的简单扼要描述;点击initialize this repositories with README。然后就是直接点击Creat repositories,创建仓库。
    第四步、开始git命令上传代码。
    1.cd到目标文件夹。
    2.git init。(在本机上想要创建一个新的git仓库)
    3.git add -A (git add -A: [path]表示把中所有tracked文件中被修改过或已删除文件和所有untracted的文件信息添加到索引库,省略表示.,即当前目录。 )
    4.git remote add origin xxxxxxxxx xxxxxx就是你仓库的地址,具体的地址可以去Github上copy。关联远程仓库。
    5.git commit -m “提交信息”
    6.git pull –rebase origin master 更新远程更新到本地: 推送本地更新到远程:(注意rebase前面是两个-,不是一个-,而是 –杠杠,哈哈,别搞错了)。
    7.git push origin master(git push -u origin master) 将本地repo于远程的origin的repo合并,第一次用-u,系统要求输入账号密码
    8.git pull (上传add的代码)
    9.去Github上面检查代码,已经上传成功。

    相关文章

      网友评论

          本文标题:GitHub简单使用

          本文链接:https://www.haomeiwen.com/subject/riwthxtx.html