修补

You've discovered a bug or something else you want to change in `Sage Notebook`_ |emdash| excellent!

你已经找到了解决问题的方法 |emdash| 甚至更好!

你想告诉我们 |emdash| 最好的!

最简单的方法是 补丁 或者一组补丁。这里我们来解释一下。

制作补丁简单快捷,但它不是我们正常工作流程的一部分。因此,如果你要做的任何事情不仅仅是一次性补丁,请考虑遵循 Git开发 取而代之的是模型。尤其是关于“拉取请求”的部分 编辑工作流程 .

制作补丁

概述

# tell git who you are
git config --global user.email you@yourdomain.example.com
git config --global user.name "Your Name Comes Here"
# get the repository if you don't have it
git clone git://github.com/sagemath/sagenb.git
# make a branch for your patching
cd sagenb
git branch the-fix-im-thinking-of
git checkout the-fix-im-thinking-of
# hack, hack, hack
# Tell git about any new files you've made
git add somewhere/tests/test_my_bug.py
# commit work in progress as you go
git commit -am 'BF - added tests for Funny bug'
# hack hack, hack
git commit -am 'BF - added fix for Funny bug'
# make the patch files
git format-patch -M -C master

您可以将生成的修补程序文件附加到 `Sage Notebook mailing list`_ 或者更好,在 `Sage Notebook github`_ 现场(见 Git开发 )把你的补丁剪下来贴在评论里。不管怎样,我们都会热烈感谢你。

细节

  1. 告诉Git你是谁,这样它就可以标记你所做的承诺:

    git config --global user.email you@yourdomain.example.com
    git config --global user.name "Your Name Comes Here"
    
  2. 如果您还没有,请克隆 `Sage Notebook`_ 储存库:

    git clone git://github.com/sagemath/sagenb.git
    cd sagenb
    
  3. 制作一个“功能分支”。这将是您修复bug的地方。它很好而且安全,让您可以访问主分支中未修改的代码副本:

    git branch the-fix-im-thinking-of
    git checkout the-fix-im-thinking-of
    
  4. 进行一些编辑,并在执行过程中提交它们:

    # hack, hack, hack
    # Tell git about any new files you've made
    git add somewhere/tests/test_my_bug.py
    # commit work in progress as you go
    git commit -am 'BF - added tests for Funny bug'
    # hack hack, hack
    git commit -am 'BF - added fix for Funny bug'
    

    注意 -am 选项到 commit . 这个 m 标志只是表示您要在命令行上键入消息。这个 a 旗帜 |emdash| 你只要有信心 |emdash| 或看到 `why the -a flag?`_ .

  5. 完成后,检查是否已提交所有更改::

    git status
    
  6. 最后,将您的提交提交到补丁中。你想要所有的承诺,因为你从 master 分支机构:

    git format-patch -M -C master
    

    现在,您将有几个为提交命名的文件:

    0001-BF-added-tests-for-Funny-bug.patch
    0002-BF-added-fix-for-Funny-bug.patch
    

    虽然有些项目会要求您将这些文件发送到 `Sage Notebook mailing list`_ ,我们更希望在web界面向 `Sage Notebook github`_ 第页。看到了吗 编辑工作流程 了解如何在创建Github帐户后创建“拉取请求”。

完成后,要切换回代码的主副本,只需返回到 master 分支机构:

git checkout master

从修补到开发

如果您发现已经完成了一些补丁,并且您有一个或多个功能分支,那么您可能需要切换到开发模式。您可以使用您拥有的存储库来完成此操作。

`Sage Notebook`_ Github上的存储库 |emdash| 制作你自己的Sage笔记本(叉子) . 然后:

# checkout and refresh master branch from main repo
git checkout master
git pull origin master
# rename pointer to main repository to 'upstream'
git remote rename origin upstream
# point your repo to default read / write to your fork on github
git remote add origin git@github.com:your-user-name/sagenb.git
# push up any branches you've made and want to keep
git push origin the-fix-im-thinking-of

然后,如果您愿意,可以按照 开发工作流程 .