您的位置:首页 > 其它

复制仓库

2014-01-23 11:28 381 查看
例:使用在GitHub.com上Spoon-Knife项目
1、复制Spoon-Knife仓库
在GitHub.com 仓库点击“Fork”按钮
2、Clone your fork(分支)
复制fork到你本地机器上
git clone https://github.com/username/Spoon-Knife.git #Clones your fork of the repository into the current directory in terminal
3、Configure remotes配置远端
完成仓库复制后,它有一个默认称为origin的远端指向你在GitHub上的分支,而非最原始仓库。为跟踪最原始仓库,你必须添加另一个名为upstream远端
$cd Spoon-Knife
# Changes the active directory in the prompt to the newly cloned
"Spoon-Knife" directory
$git remote add upstream https://github.com/octocat/Spoon-Knife.git # Assigns the original repository to a remote called "upstream"
git fetch upstream
# Pulls in changes not present in your local repository, without modifying your files提取变化不会显示在你本地仓库里,不会改变你的文件

你还可以做更多的事

1、Push commits
$git push origin master
# Pushes commits to your remote repository stored on GitHub
上传文件到远端仓库

2、Pull in upstream changes提取upstream更新
$git fetch upstream
# Fetches any new changes from the original repository
git merge upstream/master
# Merges any changes fetched into your working files

pull和fetch区别:
$git pull upstream master
# Pulls commits from 'upstream' and stores them in the local repository
pull自动完成merge,并保存到你的仓库

$git fetch upstream
# Fetches any new commits from the original repository
$git merge upstream/master
# Merges any fetched commits into your working files

3、创建分支
$git branch mybranch
$git cheakout mybranch切换到分支
$git checkout master切换到主分支
$git merge mybranch 合并分支到主分支
$git branch -d mybranch删除分支

4、pull requests
如果你想对项目有所贡献,你可以发送给原作者pull request
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  项目 active 仓库