如何为新文件创建补丁?

发布于 2024-11-01 01:54:14 字数 450 浏览 0 评论 0原文

我知道为现有文件创建补丁很容易:

diff -aru oldFile newFile 2>&1 | tee myPatch.patch

但是,如果我想为全新文件创建补丁,该怎么办?假设我的文件位于名为 TestDir 的文件夹中。早期的 TestDir 没有名为 entirelyNewfile.c 的文件,但现在有了相同的文件。

如何为entirelyNewfile.c创建补丁?这个想法是,补丁应该正确应用到规范并生成 RPM 版本。 BUILD 目录有这个新文件。

只是补充一下:如果我尝试在两个目录之间进行比较(一个目录包含新文件,另一个目录缺少相同文件)来创建补丁,则会生成一条错误,指出该文件仅存在于一个文件夹中

I know to create a patch for an existing file is easy:

diff -aru oldFile newFile 2>&1 | tee myPatch.patch

But what to do, if i want to create a patch for a totally new file? Assume my file is residing in a folder called TestDir. Earlier TestDir did not have a file called entirelyNewfile.c, but now it is having the same.

How to create a patch for entirelyNewfile.c? The idea is, the patch should get properly applied to the specs and generate the RPM build. With BUILD dir having this new file.

Just to add: if i try to take diff between the two directories, one having the new file and the other missing the same, to create the patch, it generates an error saying that file is only present in one folder

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忆梦 2024-11-08 01:54:14

-N 添加到 diff 参数中。

Add -N to the diff arguments.

生来就爱笑 2024-11-08 01:54:14
diff /dev/null <newfile>

将为您的新文件创建一个补丁。

diff /dev/null <newfile>

Will create a patch for your newfile.

╰沐子 2024-11-08 01:54:14

据我所知,最简单的方法是将所有文件置于版本控制之下(如果还没有的话)。我更喜欢 Git,但类似的事情可以在任何其他版本控制系统中完成:

git init
git add .
git commit -m "initial state"
<do your edits here>
git add .
git commit -m "new state"
git diff HEAD^1

The easiest way to do this that I know is to put all the files under version control (if they aren't already). I prefer Git, but something similar could be done in any other version control system:

git init
git add .
git commit -m "initial state"
<do your edits here>
git add .
git commit -m "new state"
git diff HEAD^1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文