2,833 questions
1765
votes
13
answers
1.2m
views
How can I generate a Git patch for a specific commit?
I want to create a patch for a specific commit hash, <rev>.
I tried using git format-patch <rev>, but that generated a patch for each commit since the <rev> commit. Is there a way to ...
570
votes
15
answers
564k
views
git apply fails with "patch does not apply" error
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 ...
453
votes
7
answers
597k
views
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?
447
votes
5
answers
266k
views
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 ...
319
votes
8
answers
375k
views
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 ...
306
votes
5
answers
156k
views
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.
275
votes
10
answers
193k
views
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 ...
260
votes
4
answers
64k
views
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 ...
245
votes
6
answers
257k
views
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 ...
233
votes
4
answers
144k
views
What is the difference between git am and git apply?
Both git am and git apply can be used to apply patches.
It seems that git am automatically commits, whereas git apply only touches the files but doesn't create a commit. Is that the only difference?
192
votes
2
answers
100k
views
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 .. ${...
183
votes
8
answers
111k
views
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 ...
175
votes
4
answers
501k
views
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 ...
169
votes
8
answers
44k
views
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 ...
162
votes
6
answers
102k
views
How to apply a Git patch to a file with a different name and path?
I have two repositories. In one, I make changes to file ./hello.test. I commit the changes and create a patch from that commit with git format-patch -1 HEAD. Now, I have a second repository that ...