多语言展示
当前在线:122今日阅读:23今日分享:25

如何使用githup创建一个版本库

如何在githup上创建一个版本库,并能在linux服务器上进行提交、下载、回滚代码等。这样每次自己写的代码都能及时的保存在githup上,下次找起来就很容易得多。git也是分布式的版本控制器,在没有联网的情况下也可以提交代码,提交到本地版本库。等联网的时候就可以push到远端的版本库了。
工具/原料
1

githup

2

centos7.2_x64

方法/步骤
1

在需要创建本地版本库的linux服务器上用ssh-keygen命令生成公钥私钥对,文件默认保存在/root/.ssh/id_rsa中

2

登录githup,点击右上角“Setting”,找到“SSH and GPG keys”,点击右上角的“New SSSH key”

3

cat /root/.ssh/id_rsa.pub将秘钥内容复制下里面,生成一个新的SSH keys添加完成后在linux服务器上用命令ssh -T git@github.com进行测试

4

点“+”号创建一个私有仓库版本库的名称自定义,默认选择'public'创建完成之后出现如下版本库信息,选择https

5

创建测试文件并推送到githup上[root@localhost mycode]# echo '# everycode' >> README.md[root@localhost mycode]# git add README.md[root@localhost mycode]# git commit -m 'first commit'[root@localhost mycode]# git remote add origin git@github.com:heliang5241/everycode.git[root@localhost mycode]# git push -u origin masterThe authenticity of host 'github.com (192.30.255.113)' 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)? yesWarning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.Counting objects: 3, done.Writing objects: 100% (3/3), 220 bytes, done.Total 3 (delta 0), reused 0 (delta 0)To git@github.com:heliang5241/everycode.git * [new branch]      master -> masterBranch master set up to track remote branch master from origin.

6

登录githup进行验证如下图所示,代码已经成功推送到githup上

注意事项

如果linux服务器上没有git,需要使用yum -y install git进行安装

推荐信息