Git中的补丁如何工作? [英] How do patches work in Git?

查看:88
本文介绍了Git中的补丁如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Git的新手,但熟悉SVN。作为一个测试,我使用 git init 在本地目录中创建了一个存储库。然后,我将空仓库(通过SSH使用127.0.0.1,这是我想测试的另一件事)克隆到另一个本地目录。我在库2中添加了一些文件,我做了 git add * ,最后 git commit -a -m第一个源代码 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆