Thursday, June 14, 2012

开始用 GitHub


现在免费的代码托管最出名的非Github莫属,但是我一直没有用Github,原因是因为Github没有免费的Private Repo。我之前一直是使用bitbucket的服务,可以有无限的私有Repo。最近因为学习目的,要fork一个Repo来看看,就开始使用Github。

Github有很详细的说明,我这里只是记录下来不让自己忘。
在做下面步骤之前,一定是要先安装git的。

$ git config --global user.name "myname"
$ git config --global user.email "myname@T420_Win"

make the git cache username and password for 1 hour (default is 15 mins), so you
don't need to type username and password everytime talk to remote server.

$ git config --global credential.helper 'cache --timeout=3600'

fork a repo

clone the forked repo
$ git clone git@github.com:username/Spoon-Knife.git

$ cd Spoon-Knife

Assigns the original repo to a remote called "upstream"
$ git remote add upstream git://github.com/octocat/Spoon-Knife.git

Pull the changes not present in your local repository, without modify your files
$ git fetch upstream

Pushes commits to your remote repo stored on GitHub
$ git push origin master

Fetches any new changes from the original repo and Merges any changes fetched into your working files
$ git fetch upstream

$ git merge upstream/master

No comments: