Github入門教程

jopen 10年前發布 | 20K 次閱讀 Github Git 版本控制系統

  作者:zhanhailiang 日期:2014-11-06

本文將教讀者如何使用Github代碼托管服務快速創建項目和提交代碼。

1. 去github.com注冊帳號,略;

2. 在github.com設置里添加SSH公鑰:

1). 需要在本地(linux)環境中下查看是否已生成公鑰;SSH公鑰默認儲存在賬戶的主目錄下的/.ssh目錄,如下:

[root@~/.ssh]# ls
id_rsa  id_rsa.pub  known_hosts

一般默認id_rsa.pub就是指公鑰,id_rsa是你本地的密鑰;若沒有,請使用ssh-keygen工具生成即可;

當獲取到公鑰后,請將公鑰內容 Add SSH Key即可:

20141106003719070.png

2). 接下來請在github.com上創建新倉庫,舉例創建名為wadetest倉庫:

20141106003816171.png

3). 在本地克隆wadetest倉庫:

[root@~/wade]# git clone git@github.com:billfeller/wadetest.git
Initialized empty Git repository in /root/wade/wadetest/.git/
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 3 (delta 0)
Receiving objects: 100% (6/6), done.

4). 當第三步成功后,就可以進行本地的開發測試,提交代碼等一系列操作。比如完成第一次提交動作:

  1. 進入工作目錄wadetest;
    </li>

  2. 創建新文件index2.js;
    </li>

  3. 提交index2.js到本地倉庫;
    </li>

  4. 將本地修改分支master同步到服務器git@github.com:billfeller/wadetest.git;
    </li> </ol>

    具體操作如下:

    [root@~/wade]# cd wadetest/
    [root@~/wade/wadetest]# ls
    index.js  README.md
    [root@~/wade/wadetest]# touch index2.js
    [root@~/wade/wadetest]# git add index2.js
    [root@~/wade/wadetest]# git commit -m 'first commit'
    [master ce86c0b] first commit
     Committer: root <root@AY140321223706700af3Z.(none)>
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com
    
    

    If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name <you@example.com>'
    
    

    0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 index2.js [root@~/wade/wadetest]# git remote -v origin git@github.com:billfeller/wadetest.git (fetch) origin git@github.com:billfeller/wadetest.git (push) [root@~/wade/wadetest]# git branch

    • master [root@~/wade/wadetest]# git push git@github.com:billfeller/wadetest.git master Counting objects: 3, done. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 277 bytes, done. Total 2 (delta 0), reused 0 (delta 0) To git@github.com:billfeller/wadetest.git c46ad6c..ce86c0b master -> master</pre>

      5). 至此,你的第一次提交就算完成了。

      推薦閱讀:

      《精通Git》progit-cn.pdf

      </div> 來自:http://blog.csdn.net/billfeller/article/details/40841179
 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!