要提供代码或文档,首先需要
计算机上安装了git
GitHub帐户
叉子
您可能已经拥有git;请键入 git --version . 如果安装了,你会看到 git version 2.11.0 . 如果你看到 command is not recognized , command not found 等等。, install git .
git --version
git version 2.11.0
command is not recognized
command not found
然后设置您的姓名和电子邮件:
git config --global user.email you@yourdomain.example.com git config --global user.name "Your Name"
如果您没有GitHub帐户,请访问https://github.com/join创建一个。
Forking 有两个步骤——访问GitHub在您的帐户中创建fork repo,然后在您自己的机器上复制它。
Forking
登录您的GitHub帐户。
去 NumPy GitHub home .
在页面的右上角,单击 Fork :
Fork
你会看到的
然后,您将被带到您的分叉副本的主页:
在要创建副本的目录中,运行:
git clone https://github.com/your-user-name/numpy.git
$ git clone https://github.com/your-user-name/numpy.git Cloning into 'numpy'... remote: Enumerating objects: 12, done. remote: Counting objects: 100% (12/12), done. remote: Compressing objects: 100% (12/12), done. remote: Total 175837 (delta 0), reused 0 (delta 0), pack-reused 175825 Receiving objects: 100% (175837/175837), 78.16 MiB | 9.87 MiB/s, done. Resolving deltas: 100% (139317/139317), done.
目录 numpy 在您的计算机上创建。(如果您已经有一个numpy目录,GitHub将选择一个不同的名称,如 numpy-1 .)
numpy
numpy-1
$ ls -l total 0 drwxrwxrwx 1 bjn bjn 4096 Jun 20 07:20 numpy
说出你的名字 upstream 到主NumPy回购:
upstream
cd numpy git remote add upstream https://github.com/numpy/numpy.git
设置存储库以便 git pull 拉扯 upstream 默认情况下:::
git pull
git config branch.master.remote upstream git config branch.master.merge refs/heads/master
所示的分支 git branch -a 将包括
git branch -a
这个 master 你刚刚在自己的机器上克隆的分支
master
这个 master 从GitHub上的fork分支,git将其命名为 origin 默认情况下
origin
这个 master 在你命名的主NumPy回购上的分支 upstream .
master remotes/origin/master remotes/upstream/master
如果 upstream 不是吗,它会在你访问NumPy repo之后添加,比如 git fetch 或 git pull .
git fetch
回购协议 git remote -v show 将包括您在GitHub上的fork和主回购:::
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)
git config --list 将包括:
git config --list
user.email=your_email@example.com user.name=Your Name remote.origin.url=git@github.com:your-github-id/numpy.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=upstream branch.master.merge=refs/heads/master remote.upstream.url=https://github.com/numpy/numpy.git remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
克隆numpyfork repo不需要密码,因为它读取远程repo而不更改它。不过,稍后提交拉取请求时,会向它写入请求,GitHub会请求您的用户名和密码——尽管这是您自己的repo。您可以通过 setting up SSH keys .
如果你在克隆之前设置了密钥 ,以上说明略有变化。而不是::
跑步:
git clone git@github.com:numpy/numpy.git
而不是表现出 https 网址, git remote -v 将显示:
https
git remote -v
origin git@github.com:your-user-name/numpy.git (fetch) origin git@github.com:your-user-name/numpy.git (push)
如果你已经克隆了 要开始使用SSH,请参阅 Switching remote URLs from HTTPS to SSH .