Github Manual

github文檔庫: https://help.github.com/articles/


(一) 安裝配置git

1. 安裝git

2. username:顯示在commit歷史中,標識提交者

$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit

3. email:保存在commit中,github通過該email關聯到github賬戶

$ git config --global user.email "[email protected]"
# Sets the default email for git to use when you commit


4. 使用password caching,僅對git version > 1.7.10有效

在一定時間內,不用每次輸入password

默認緩存15分鐘

$ git config --global credential.helper cache
# Set git to use the credential memory cache

改變緩存時間,單位爲秒

$ git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)

(二) 創建repository

1. github上點擊“new repository”

2. 在本地添加文件,以README爲例

$ mkdir ~/Hello-World
# Creates a directory for your project called "Hello-World" in your user directory

$ cd ~/Hello-World
# Changes the current working directory to your newly created directory

$ git init
# 初始化,Sets up the necessary Git files
# Initialized empty Git repository in /Users/you/Hello-World/.git/

$ touch README
# 創建README,向其添加內容


3. commit 所做改動

$ git add README
# Stages your README file, adding it to the list of files to be committed

$ git commit -m 'first commit'
# -m內容進入commit歷史,可用git log查看

4. 推送到遠端git庫

$ git remote add origin https://github.com/username/Hello-World.git
# “username”爲github用戶名
# 禁止https訪問時,可用http代替

$ git push origin master
# Sends your commits in the "master" branch to GitHub

5. 用git clone驗證推送是否成功

$ mkdir ~/test_push
$ cd ~/test_push
$ git clone https://github.com/username/Hello-World.git




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章