Git开发入门¶
这一节和下一节将详细描述如何设置GIT以使用SciPy源代码。如果您已经设置了GIT,请跳到 开发工作流 。
基本Git设置¶
安装Git 。
向Git介绍自己::
git config --global user.email you@yourdomain.example.com git config --global user.name "Your Name Comes Here"
制作您自己的SciPy副本(分叉)¶
您只需要这样做一次。这里的说明与http://help.github.com/forking/上的说明非常相似-请参阅该页面以了解更多详细信息。我们在这里重复其中的一些内容,只是为了给出 SciPy 项目,并建议一些默认名称。
设置和配置 github 帐户¶
如果你没有一个 github 帐户,请转到 github 翻一页,做一张。
然后,您需要配置您的帐户以允许写访问-请参阅 Generating SSH keys
关于以下内容的帮助 github help 。
创建您自己的分叉副本 SciPy¶
登录到您的 github 帐户。
请转到 SciPy GitHub主页位于 SciPy github 。
单击 fork 按钮:
稍作停顿后,您会发现自己在主页上找到了您自己的分叉副本 SciPy.
摆好你的叉子¶
首先,您要按照以下说明进行操作 制作您自己的SciPy副本(分叉) 。
概述¶
git clone https://github.com/your-user-name/scipy.git
cd scipy
git remote add upstream https://github.com/scipy/scipy.git
详细地说¶
克隆你的叉子¶
使用以下命令将您的分支克隆到本地计算机
git clone https://github.com/your-user-name/scipy.git
调查一下。将目录更改为您的新存储库:
cd scipy
。然后git branch -a
向你们展示所有的分支机构。您将得到如下内容::* master remotes/origin/master
这会告诉您,您当前处于
master
分支,并且您还拥有一个remote
连接到origin/master
。什么是远程存储库remote/origin
?试试看git remote -v
查看遥控器的URL。他们会指向你的 github 叉子。现在您想要连接到上游 SciPy github 存储库,因此您可以合并来自主干的更改。
将存储库链接到上游回购¶
cd scipy
git remote add upstream https://github.com/scipy/scipy.git
upstream
这里只是我们用来指代Main的任意名称 SciPy 存储库位于 SciPy github 。
仅仅为了你自己的满足,展示你自己,你现在有了一个新的“遥控器”, git remote -v show
,为您提供类似以下内容的信息::
upstream https://github.com/scipy/scipy.git (fetch)
upstream https://github.com/scipy/scipy.git (push)
origin https://github.com/your-user-name/scipy.git (fetch)
origin https://github.com/your-user-name/scipy.git (push)
要与SciPy中的更改保持同步,您需要设置存储库,以便从 upstream
默认情况下。这可以通过以下方式实现:
git config branch.master.remote upstream
git config branch.master.merge refs/heads/master
您的配置文件现在应该类似于(来自 $ cat .git/config
):
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
url = https://github.com/your-user-name/scipy.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "upstream"]
url = https://github.com/scipy/scipy.git
fetch = +refs/heads/*:refs/remotes/upstream/*
[branch "master"]
remote = upstream
merge = refs/heads/master