Questions tagged [git-patch]

98 questions
1546
votes
26 answers

How can I selectively merge or pick changes from another branch in Git?

I'm using Git on a new project that has two parallel -- but currently experimental -- development branches: master: import of existing codebase plus a few modifications that I'm generally sure of exp1: experimental branch #1 exp2: experimental…
David Joyner
  • 19,979
  • 4
  • 25
  • 33
1001
votes
7 answers

Create a git patch from the uncommitted changes in the current working directory

Say I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit?
vrish88
  • 16,893
  • 8
  • 36
  • 54
153
votes
5 answers

How can I format patch with what I stash away

In git, I stash away my changes. Is it possible that I can create a patch with what I stash away? And then apply that patch in some other repository (my co-worker's)? I know git format-patch -1, but I think that it's for what I have committed. But…
silverburgh
  • 7,129
  • 10
  • 28
  • 23
112
votes
6 answers

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 contains a file that has the same contents as…
mart1n
  • 5,135
  • 5
  • 35
  • 72
111
votes
5 answers

What does "1 line adds whitespace errors" mean when applying a patch?

I'm editing some markdown files of a cloned remote repository, and wanted to test creating and applying patches from one branch to another. However, every time I make any change at all, I get the following message during git apply: 0001-b.patch:16:…
Yarin
  • 144,097
  • 139
  • 361
  • 489
84
votes
7 answers

How to apply a git patch from one repository to another?

I have two repositories, one is the main repo for a library, and the other is a project using that library. If I make a fix to the in the subservient project, I'd like an easy way to apply that patch back upstream. The file's location is different…
James Wheare
  • 4,379
  • 1
  • 22
  • 22
73
votes
1 answer

How to generate patch for all commits in a branch?

How can I generate patch for all commits in a given branch by knowing only the branch name? This step is part of a complex workflow all of which is being automated. Hence requiring someone to manually determine the first commit in the branch is not…
akirekadu
  • 1,954
  • 2
  • 21
  • 28
21
votes
3 answers

Use Git's patience diff algorithm for interactive add

I'd like to use Git's patience diff algorithm (the one you get if you invoke git diff with the --patience argument) with git add -p. How can I do this? Background: I'm working with some XML files, and git diff's normal algorithm produces pretty poor…
me_and
  • 13,911
  • 6
  • 58
  • 93
14
votes
4 answers

git: Patch does not have a valid e-mail address

I have a patch-file. I want to apply this patch to my code in git repository. When I used subversion this process was quite simple: right click -> tortoise svn -> apply patch. It always works as I expected. But I cannot do this using git. Git…
tmporaries
  • 1,343
  • 7
  • 21
  • 35
13
votes
2 answers

Apply Bitbucket pull request as a patch

I've got a repo on Bitbucket that only I have write access to. Someone forked that repo, made changes and issued a pull request to my repo from the fork. How can I get that pull request as a git patch to apply temporarily to my repo for testing…
Nick Spiers
  • 2,294
  • 2
  • 19
  • 30
8
votes
2 answers

What is the difference between git cherry-pick and git format-patch | git am?

I sometimes need to cherry-pick a tag with a certain fix into my branch, and used to do so via git cherry-pick tags/myfix This works, but cherry-picking takes an increasingly long time doing "inexact rename detection". My hunch was that this could…
Felix Dombek
  • 11,461
  • 15
  • 67
  • 116
8
votes
2 answers

Can I make git add -p show changes like git diff --word-diff?

I have recursively replaced many single word patterns in my code base. Before committing I need to check each for false replacements. It would help me a lot to have git add -p use the format of what --word-diff uses with git diff, where only the…
djangonaut
  • 5,938
  • 5
  • 32
  • 44
8
votes
3 answers

Create Git patches for two files across several renames

I want to move two files from one repository to another. The files were originally added as: /src/init/Price.cs /tests/init/PriceTests.cs The two files were later renamed to: /src/init/PriceValue.cs /tests/init/PriceValueTests.cs And then moved…
Asbjørn Ulsberg
  • 8,212
  • 2
  • 41
  • 60
8
votes
2 answers

git pull remote master in detached head

This has been bothering me about git. I have a repository with multiple remotes, and I need to apply hotfixes to the remotes' master branches. So, I try doing: git fetch remote1 master git checkout remote1/master But, I always end up in a…
user2659205
  • 137
  • 1
  • 6
8
votes
2 answers

Manually editing using git add --patch

So, I've got a file I've been working on in branch A, and I'm just about ready to commit it. However, looking at the diff, I think it's better to put it into two separate commits (Well, in this case, two separate branches, maybe). I've used git…
Jason_L_Bens
  • 354
  • 2
  • 14
1
2 3 4 5 6 7