本节和下一节将详细描述如何设置git以使用NumPy源代码。如果您已经设置了git,请跳至 开发工作流程。
向Git介绍自己:
git config --global user.email you@yourdomain.example.com
git config --global user.name "Your Name Comes Here"
您只需要这样做一次。这里的说明与http://help.github.com/forking/上的说明非常相似-请参阅该页面以获取更多详细信息。我们在这里重复其中的一些只是为了提供NumPy项目的细节,并建议一些默认名称。
首先,您要遵循制作NumPy的副本(分叉)的说明。
git clone https://github.com/your-user-name/numpy.git
cd numpy
git remote add upstream https://github.com/numpy/numpy.git
使用以下命令将fork复制到本地计算机 git clone
https://github.com/your-user-name/numpy.git
调查。将目录更改为您的新仓库:。然后
向您展示所有分支。您会得到类似的信息:cd numpy
git branch -a
* master
remotes/origin/master
这告诉您您当前在master
分支上,并且您也有与的remote
连接origin/master
。什么是远程存储库remote/origin
?尝试查看遥控器的URL。他们将指向您的github分支。git remote -v
现在,您想连接到上游的NumPy github存储库,以便可以合并主干中的更改。
cd numpy
git remote add upstream https://github.com/numpy/numpy.git
upstream
这只是我们用来引用NumPy github上主要NumPy存储库的任意名称。
只是为了您自己的满意,请显示,您现在有了一个新的'remote' ,为您提供了类似以下内容:git remote -v show
upstream https://github.com/numpy/numpy.git (fetch)
upstream https://github.com/numpy/numpy.git (push)
origin https://github.com/your-user-name/numpy.git (fetch)
origin https://github.com/your-user-name/numpy.git (push)
为了与NumPy中的更改保持同步,您需要设置存储库,使其upstream
默认情况下从存储库中提取。这可以通过以下方式完成:
git config branch.master.remote upstream
git config branch.master.merge refs/heads/master
您可能还想轻松访问发送到NumPy存储库的所有拉取请求:
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/pr/*'
您的配置文件现在应类似于(from
):$ 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/numpy.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "upstream"]
url = https://github.com/numpy/numpy.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
[branch "master"]
remote = upstream
merge = refs/heads/master