Questions tagged [patch]

A patch is a piece of software designed to fix problems with, or update a computer program or its supporting data. This includes fixing security vulnerabilities and other bugs, and improving the usability or performance.

Programmers publish and apply patches in various forms. Because proprietary software authors withhold their source code, their patches are distributed as binary executables instead of source. This type of patch modifies the program executable—the program the user actually runs—either by modifying the binary file to include the fixes or by completely replacing it.

Patches can also circulate in the form of source code modifications. In these cases, the patches consist of textual differences between two source code files. These types of patches commonly come out of open source projects. In these cases, developers expect users to compile the new or changed files themselves.

Because the word "patch" carries the connotation of a small fix, large fixes may use different nomenclature. Bulky patches or patches that significantly change a program may circulate as "service packs" or as "software updates". Microsoft Windows NT and its successors (including Windows 2000, Windows XP, and later versions) use the "service pack" terminology.

In several Unix-like systems, particularly Linux, updates between releases are delivered as new software packages. These updates are in the same format as the original installation so they can be used either to update an existing package in-place (effectively patching) or be used directly for new installations.

2809 questions
1609
votes
11 answers

How can I generate a Git patch for a specific commit?

I need to write a script that creates patches for a list of SHA-1 commit numbers. I tried using git format-patch , but that generated a patch for each commit since that SHA-1 value. After a few hundred patches were generated, I had to kill…
elle
  • 16,125
  • 3
  • 15
  • 4
509
votes
13 answers

git: patch does not apply

I have a certain patch called my_pcc_branch.patch. When I try to apply it, I get following message: $ git apply --check my_pcc_branch.patch warning: src/main/java/.../AbstractedPanel.java has type 100644, expected 100755 error: patch failed:…
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
441
votes
5 answers

How to move certain commits to be based on another branch in git?

The situation: master is at X quickfix1 is at X + 2 commits Such that: o-o-X (master HEAD) \ q1a--q1b (quickfix1 HEAD) Then I started working on quickfix2, but by accident took quickfix1 as the source branch to copy, not the master.…
Alex Yarmula
  • 10,477
  • 5
  • 33
  • 32
373
votes
7 answers

How to apply a patch generated with git format-patch?

I have two local git repositories, both pointing to the same remote repository. In one git repository, if I do git format-patch 1, how can I apply that patch to the other repository?
silverburgh
  • 8,659
  • 10
  • 31
  • 24
302
votes
5 answers

How to apply `git diff` patch without Git installed?

How can my client apply patch created by git diff without git installed? I have tried to use patch command but it always asks file name to patch.
Andrey Kuznetsov
  • 11,640
  • 9
  • 47
  • 70
275
votes
6 answers

Create patch or diff file from git repository and apply it to another different git repository

I work on WordPress based project and I want to patch my project at each new release version of WP. For this, I want generate a patch between two commits or tags. For example, in my repo /www/WP I do this: $ git patch-format com1..com2 --stdout >…
zatamine
  • 3,458
  • 3
  • 25
  • 33
255
votes
10 answers

What is the main difference between PATCH and PUT request?

I am using a PUT request in my Rails application. Now, a new HTTP verb, PATCH has been implemented by browsers. So, I want to know what the main difference between PATCH and PUT requests are, and when we should use one or the other.
user3276063
  • 2,583
  • 2
  • 13
  • 7
251
votes
4 answers

Can I split an already split hunk with git?

I've recently discovered git's patch option to the add command, and I must say it really is a fantastic feature. I also discovered that a large hunk could be split into smaller hunks by hitting the s key, which adds to the precision of the…
greg0ire
  • 22,714
  • 16
  • 72
  • 101
225
votes
6 answers

How do I simply create a patch from my latest git commit?

I am looking for the command for creating a patch from the last commit made. My workflow sometimes looks like this: vi some.txt git add some.txt git commit -m "some change" Now I just want to write: git create-patch-from-last-commit-to-file…
claj
  • 5,172
  • 2
  • 27
  • 30
204
votes
3 answers

What is the difference between git am and git apply?

Both git am and git apply can be used to apply patches. I fail to see the difference. I see a difference now: git am automatically commits whereas git apply only touches the files but doesn't create a commit. Is that the only difference?
Christoph
  • 26,519
  • 28
  • 95
  • 133
179
votes
8 answers

How do you squash commits into one patch with git format-patch?

I've got eight commits on a branch that I'd like to email to some people who aren't git enlightened, yet. So far, everything I do either gives me 8 patch files, or starts giving me patch files for every commit in the branch's history, since the…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
164
votes
2 answers

How to download a single commit-diff from GitHub?

I would like to get a single commit (let's call it ${SHA}) from GitHub via the web-interface. For example, something like: $ git clone http://github.com/foo/bar $ cd bar $ git format-patch -o .. ${SHA}~1..${SHA} $ cd .. $ rm -rf bar ...but without…
umläute
  • 28,885
  • 9
  • 68
  • 122
155
votes
7 answers

How can I visualize per-character differences in a unified diff file?

Say I get a patch created with git format-patch. The file is basically a unified diff with some metadata. If I open the file in Vim, I can see which lines have been modified, but I cannot see which characters in the changed lines differ. Does anyone…
Adam Monsen
  • 9,054
  • 6
  • 53
  • 82
152
votes
4 answers

Using python's mock patch.object to change the return value of a method called within another method

Is it possible to mock a return value of a function called within another function I am trying to test? I would like the mocked method (which will be called in many methods I'm testing) to returned my specified variables each time it is called. For…
mdoc-2011
  • 2,747
  • 4
  • 21
  • 43
148
votes
23 answers

How do I apply a diff patch on Windows?

There are plenty of programs out there that can create a diff patch, but I'm having a heck of a time trying to apply one. I'm trying to distribute a patch, and I got a question from a user about how to apply it. So I tried to figure it out on my own…
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
1
2 3
99 100