1. 程式人生 > >Git總結筆記3-把本地倉庫推送到github

Git總結筆記3-把本地倉庫推送到github

-c don gin 目的 commit 筆記 pre git from

說明:此筆記在centos 7 上完成

1.配置公鑰

[[email protected] ~]# ssh-keygen -t rsa -C "[email protected]"
[[email protected] ~]# cat .ssh/id_rsa.pub

註意:在本地用ssh-keygen生成密鑰對後,把公鑰添加到github上

2.安裝git服務

[[email protected] ~]# yum -y install git

3.配置基本環境參數

[[email protected]
/* */ ~]# git config --global user.name "kangvcar" [[email protected] ~]# git config --global user.email "[email protected]"

4.創建本地倉庫目錄並初始化

[[email protected] ~]# mkdir kangvcar    
[[email protected] ~]# cd kangvcar/
[[email protected] kangvcar]# git init
[[email protected]
/* */ kangvcar]# echo "ni hao kangvcar" >> test.txt

5.將項目的所有文件添加到倉庫中,並commit

[[email protected] kangvcar]# git add .
[[email protected] kangvcar]# git commit -m "add test.txt"

6.到github上創建自己的Repository,名字可以不同

7.進入到新建的Repository,獲取項目的地址

如地址:[email protected]

:kangvcar/kangvcar.git

8.將本地倉庫與遠程倉庫關聯

[[email protected] kangvcar]# git remote add origin [email protected]:kangvcar/kangvcar.git

9.將本地倉庫推送到github上

[[email protected] kangvcar]# git push -u origin master
Warning: Permanently added the RSA host key for IP address 192.30.255.112 to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 222 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:kangvcar/kangvcar.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

10.在github上就能看到推送的更新了

Git總結筆記3-把本地倉庫推送到github