打一块补丁¶
您发现了错误或其他您想要更改的内容 scikit-image 。。 — 好极了!
你已经想出了解决问题的办法 — 更棒的是!
你想给我们讲讲吗? — 最棒的是!
最简单的方法是制作一个 补丁 或一组补丁。下面我们来解释一下是如何做到的。打补丁是最简单、最快的,但如果你想做的不只是简单快捷的事情,请考虑遵循 用于开发的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/scikit-image/scikit-image.git
# make a branch for your patching
cd scikit-image
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
Then, send the generated patch files to the scikit-image mailing list — where we will thank you warmly.
详细地说¶
告诉Git你是谁,这样它就可以标记你所做的承诺::
git config --global user.email you@yourdomain.example.com git config --global user.name "Your Name Comes Here"
如果您还没有,请克隆一个 scikit-image 存储库::
git clone git://github.com/scikit-image/scikit-image.git cd scikit-image
做一个‘特色分支’。这将是您修复错误的地方。它很好很安全,让您可以访问主分支中的代码的未经修改的副本::
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'
请注意
-am
选项至commit
。这个m
标志只是表示您要在命令行中键入消息。这个a
旗子 — 你可以只接受信仰 — 或查看 why the -a flag? 。完成后,检查是否已提交所有更改::
git status
最后,把你的承诺打成补丁。您想要所有提交,因为您从
master
分支机构::git format-patch -M -C master
现在,您将拥有几个命名为Commit::的文件
0001-BF-added-tests-for-Funny-bug.patch 0002-BF-added-fix-for-Funny-bug.patch
将这些文件发送到 scikit-image mailing list 。
完成后,要切换回代码的主副本,只需返回 master
分支机构::
git checkout master
从打补丁到开发¶
如果您发现自己做了一些补丁,并且有一个或多个特性分支,那么您可能想要切换到开发模式。您可以使用您拥有的存储库来实现这一点。
叉子 scikit-image GitHub上的存储库 — 制作您自己的SCRKIT-IMAGE副本(分叉) 。然后::
# 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/scikit-image.git
# push up any branches you've made and want to keep
git push origin the-fix-im-thinking-of
然后,如果您愿意,可以按照 开发工作流 。