Github顾名思义是一个Git版本库的托管服务,是目前全球最大的软件仓库,拥有上百万的开发者用户,也是软件
开发和寻找资源的最佳途径,Github不仅可以托管各种Git版本仓库,还拥有了更美观的Web界面,您的代码文件可
以被任何人克隆,使得开发者为开源项贡献代码变得更加容易,当然也可以付费购买私有库,这样高性价比的私有
库真的是帮助到了很多团队和企业
1、注册用户
2、配置ssh‐key
3、创建项目
4、克隆项目到本地
5、推送新代码到github
1. 创建仓库
[root@git git_data]#: git remote add origin git@github.com:qiufeng615/git_data.git
[root@git git_data]#: git remote
origin
[root@git git_data]#: git push -u origin master
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5: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,52.74.223.119' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
报错了,因为权限拒绝,没有做ssh认证
2. 创建公钥
[root@git ~]#: ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:U6YM4cwE4lbSgU0BPhopXI7xOsqTI8qsJiljCakWaN0 root@git
The key's randomart image is:
+---[RSA 2048]----+
| .+B*+o |
|.+B+o= . |
|+o=o = o |
|.+.. o + |
|o+. . S |
|*oo. E . |
|**o |
|@=o |
|X+ |
+----[SHA256]-----+
3. 复制公钥到github
[root@git ~]#: cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC41tBVR4hlbt3UBdRHDZrHlZWPVUtukum6Etseub4N826QhKeZ/BZmtJu/dUgi322odazuObUU6Z1ee5PV37DLREyayrevkcG/VwOycGaq4J78029wMW5Kq1mDvHGlXgw2x5kFl0s+6dtMSECudzuOAZYrS9QgaCP+h/hSB8JKD/rKW56QvEQ9hpK/wRdgF/xNgDao0EPxwjGgALZbIPYzu41jqGjFvavf1Ucu5EicJelw8ZDc6e3MQ8RvioC42vlroC87B/6tsQjLlp5Y1WZFBm9tpzgWoZ2EKhzRROC7LVEbPF98cM1o1DxL5kMfM7T3bP7G1dE8LrQ/3HsNk5NH root@git
4. 继续推送代码到github
[root@git ~]#: cd git_data/
[root@git git_data]#: git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 199 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:qiufeng615/git_data.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
5. 克隆文件到本地
[root@git tmp]#: git clone git@github.com:qiufeng615/git_data.git
Cloning into 'git_data'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
[root@git git_data]#: pwd
/tmp/git_data
[root@git git_data]#: ll
total 0
-rw-r--r-- 1 root root 0 Apr 24 20:23 test.txt
6. 本地更改推送代码github仓库
[root@git git_data]#: echo test1 >test.txt
[root@git git_data]#: git commit -am 'add test'
[master 21cb400] add test
1 file changed, 1 insertion(+)
[root@git git_data]#: git push -u origin master
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
Counting objects: 5, done.
Writing objects: 100% (3/3), 238 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:qiufeng615/git_data.git
5929a40..21cb400 master -> master
Branch master set up to track remote branch master from origin.
7. github仓库检查
创建github并推送代码带远程仓库,简单的github操作就到这里。