git从unpushed提交创建补丁 [英] git create patch from unpushed commits

查看:110
本文介绍了git从unpushed提交创建补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在远程工作时我无法推送,所以我想从所有尚未推送到我的开发分支上的提交中创建一个单一补丁来发送电子邮件。我该怎么做?

解决方案

git format-patch< commit-ish> 为自你指定的提交后所做的每次提交创建一个补丁文件。



因此,要导出所有提交的提交,只需放入

  git format-patch origin / master -o patches / 

,并将它们全部输出到 patches / 目录中。



如果你想要一个单个文件,添加 - stdout

  git format -patch origin / master --stdout>补丁程序_ $(date -I).patch 

这将创建一个名为 patch_2014-10-03.patch (或另一个日期),其中包含所有的修补程序。 当心: 修补程序或其他简单的修补程序应用程序无法处理生成的文件。它仅适用于 git am






旁注:<
一个更容易(也更强大)的事情可能是将你的回购副本保留在拇指驱动器上或类似的东西上。然后将thumbdrive设置为一个远程( git remote add thumb / media / thumbdrive ),将你的提交按下( git push thumb master ),然后回到你的公司时,从驱动器拉出并推到原点。


I cannot push when working remotely, so I want to create a single patch from all the commits that have not yet been pushed on my develop branch to email it. How do I do that?

解决方案

git format-patch <commit-ish> creates a patch file for every commit you made since the specified commit.

So, to export all your unpushed commits, simply put

git format-patch origin/master -o patches/

and all of them will be output into the patches/ directory.

If you want to have a single file, add --stdout:

git format-patch origin/master --stdout > patches_$(date -I).patch

This will create a file named patches_2014-10-03.patch (or another date) with all your patches in it. Beware: patch or other simple patch applications cannot cope with the produced file. It will only work with git am.


Sidenote:
An easier (and more robust) thing to do might be to keep a copy of your repo on a thumbdrive or similiar. Then set up the thumbdrive as a remote (git remote add thumb /media/thumbdrive), push your commits to it (git push thumb master) and when back at your firm, pull from the drive and push to origin.

这篇关于git从unpushed提交创建补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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