Git是一個分佈式的版本控制系統,GitHub可以託管各種git庫,並提供一個web界面,但與其它像 SourceForge或Google Code這樣的服務不同,GitHub的獨特賣點在於從另外一個項目進行分支的簡易性。爲一個項目貢獻代碼非常簡單︰首先點擊項目站點的“fork”的按 鈕,然後將代碼檢出並將修改加入到剛纔分出的代碼庫中,最後通過內建的“pull request”機制向項目負責人申請代碼合併。已經有人將GitHub稱爲代碼玩家的MySpace。
http://code.google.com/p/msysgit/downloads/list
可以參考:https://help.github.com/articles/set-up-git
設置用戶名:
$ git config --global user.name "Your Name Here" # Sets the default name for git to use when you commit
設置Email,可以不用真實的Email,只是作爲一個標示:
$ git config --global user.email "[email protected]" # Sets the default email for git to use when you commit
設置密碼緩存時間:
$ 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)
可以參考:https://help.github.com/articles/create-a-repo
$ 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
# Creates a file called "README" in your Hello-World directory
$ git add README # Stages your README file, adding it to the list of files to be committed $ git commit -m 'first commit'' # Commits your files, adding the message "first commit"
使用GitHub首先要創建SSH Key。SSH將用來加密本機與遠端服務器之間的通信。同時也是識別你對代碼所做的變更的方法。SSH Key可以使用Git命令行來產生。首先打開Git Bash命令行,輸入:
ssh-keygen -C "[email protected]" -t rsa
說明:[email protected] 爲你初始化Git的設置的Email地址。
之後Git Bash命令行中,會進行一些提示:
pass phrase:如果本機安全,也可以不用輸入。
找到生成的id_rsa.pub文件,把裏面的內容複製到GitHub -> Account Settings -> SSH Keys –>Add SSH key的key輸入框中,標題自定義,進行添加一個SSH Key。
$ git remote add origin [email protected]:username/Hello-World.git # Creates a remote named "origin" pointing at your GitHub repo $ git push origin master # Sends your commits in the "master" branch to GitHub
注意,這裏的Hello-World.git是根據你在服務器上創建的倉庫名稱決定的,如果服務器創建了一個Itzhai倉庫,則這裏爲Itzhai.git。