Git中的补丁如何工作? [英] How do patches work in Git?
问题描述
我是Git的新手,但熟悉SVN。作为一个测试,我使用 git init
在本地目录中创建了一个存储库。然后,我将空仓库(通过SSH使用127.0.0.1,这是我想测试的另一件事)克隆到另一个本地目录。我在库2中添加了一些文件,我做了 git add *
,最后 git commit -a -m第一个源代码$ c $现在我想使用
git format-patch
创建一个补丁并将其应用到资源库1上。
创建你的补丁通过:
$ git format-patch master --stdout> patch.diff
然后patch.diff将包含diff,然后您可以发送给其他人申请使用:
$ git am< patch.diff
有时,当手册有点密集时,寻找教程很有意义:
http ://luhman.org/blog/2009/09/22/git-patch-tutorial
I'm new to Git, but familiar with SVN. As a test I made a repository in a local directory with git init
. Then I cloned the empty repository (over SSH using 127.0.0.1, which is another thing I wanted to test) to another local directory. I added some files in repository 2, I did git add *
and finally git commit -a -m "First source code"
.
I now want to create a patch using git format-patch
and apply it on repository 1. How do I do this? I know there's a manual, but these things are terribly complicated and make me wanna do certain things to my monitor.
Create your patch via:
$ git format-patch master --stdout > patch.diff
then patch.diff will contain the diff, which you can then send to someone else to apply using:
$ git am < patch.diff
Sometimes, when the manuals are a little dense, it makes sense to look for a tutorial:
http://luhman.org/blog/2009/09/22/git-patch-tutorial
这篇关于Git中的补丁如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!