寻找使用 git-format-patch 和 git am 的工作流示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/327249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:06:33  来源:igfitidea点击:

Seeking examples of workflow using git-format-patch and git am

gitversion-controlworkflow

提问by Norman Ramsey

I'm thinking of asking my students to use git for pair programming. Because student work has to be secret, a public repo is out of the question. Instead, each student will have a private repo they maintain themselves, and they will need to exchange patches using git-format-patch. I've read the man page but I'm a little unclear whichpatches will be sent. The obvious thing for the students would be send all patches since the last sendor (if git doesn't mind receiving the same patches redundantly) send all patches since the dawn of time. (Remember these are student projects, they last for a couple of weeks and are small, and performance is not a criterion.) Our best friend is simplicityand we are fond of brute force as well.

我正在考虑让我的学生使用 git 进行结对编程。因为学生的工作必须保密,所以不可能公开回购。相反,每个学生都有一个他们自己维护的私人仓库,他们需要使用 git-format-patch 交换补丁。我已经阅读了手册页,但我有点不清楚将发送哪些补丁。对于学生来说,显而易见的事情是发送自上次发送以来的所有补丁,或者(如果 git 不介意重复接收相同的补丁)发送所有补丁。(请记住,这些是学生项目,它们持续几个星期,规模很小,性能不是标准。)我们最好的朋友是简单我们也喜欢蛮力。

Can anyone give me a short series of examples that show two people, each with a private git repo, exchanging patches using git-format-patch and git-am? Or alternatively point me to existing git documentation and/or tutorial?

谁能给我一个简短的例子,展示两个人,每个人都有一个私人 git 仓库,使用 git-format-patch 和 git-am 交换补丁?或者指向我现有的 git 文档和/或教程?

回答by Dustin

It works best if they can see each other's git repos. git itself is managed this way (there's a public repo people can reference, and then they format-patch from there). If people neversee each other's repos, things are a bit more difficult...

如果他们可以看到彼此的 git 存储库,则效果最佳。git 本身就是以这种方式管理的(人们可以参考一个公共仓库,然后他们从那里格式化补丁)。如果人们从来没有看到彼此的回购,事情就会有点困难......

One thing they may do is maintain a reference to the last time they did a format patch. Let's say they start by just sending their entire tree (including .git):

他们可能会做的一件事是维护对上次进行格式补丁的引用。假设他们首先发送整个树(包括 .git):

tar cvf - mytree | gzip -9vc > /tmp/mytree.tgz
# mail /tmp/mytree.tgz
git tag last-send
# hack, commit, hack, commit
git format-patch -M -C last-send..
# mail 00* && rm 00*
git tag -f last-send

git tagin this form creates a "lightweight tag. It's a sort of bookmark. This will be an easy way for people to keep track of what they sent so they can send it again next time.

git tag在这种形式中创建一个“轻量级标签。它是一种书签。这将是人们跟踪他们发送的内容的一种简单方法,以便他们下次可以再次发送。

On the other side:

另一方面:

# get patches from mail and place in /tmp
git am /tmp/00*
rm /tmp/00*

回答by Sukima

It seems that git bundleis the better option. Unlike git format-patchwhich is a one-way communication workflow, bundle allows you to leverage the same workflow you use with public remotes but are separated from direct access.

似乎这git bundle是更好的选择。与git format-patch单向通信工作流不同,bundle 允许您利用与公共遥控器相同的工作流,但与直接访问分开。

It is designed for sneaker-nets and would be perfect for students to save to USB or email bundles.

它专为运动鞋网而设计,非常适合学生保存到 USB 或电子邮件包中。

patches are more for submit for approval by a project lead style of communicating.

补丁更多的是提交给项目主管沟通方式的批准。