Questions tagged [git-patch]
108 questions
4
votes
1 answer
Git apply patch to specific file outside of git repo
I have two files, x_original.txt and x_updated.txt.
I used the following command to obtain a patch file:
git diff --no-index x_original.txt x_updated.txt > fix_something.patch
I now want to apply this patch to a file called x.txt.
The following is…

David Callanan
- 5,601
- 7
- 63
- 105
4
votes
1 answer
Git workflow when you cant push or pull
This is a recurring question for me, but I'd like to reiterate.
Quickly explain my situation: I am in an environment where I don't have a a git server, nor a shared partition or any common point among the coders. Don't have, will not have, can not…

filippo
- 5,583
- 13
- 50
- 72
4
votes
0 answers
git apply patch exclude 2 files
How do you git apply patch but exclude 2 files? For 1 file or file pattern you could do --exclude flag. But what if I have 2 different files a.rb and b.rb I need to exclude but I have c.rb, d.rb, e.rb also in the patch which needs to be applied.

rubyprince
- 17,559
- 11
- 64
- 104
4
votes
2 answers
How to apply all git .patch files from /patches folder - npm
TL,DR;
I'm looking for a git command, bash script or npm method (script) to take all .patch files in a folder and run
git apply --ignore-whitespace patches/{filename}
What I've tried so far:
git am --ignore-whitespace patches/*.patch
Context…

tao
- 82,996
- 16
- 114
- 150
4
votes
3 answers
Reapply Git commits from copied fork repository to original repository
A university colleague of mine thought it was a good idea to fork a repository by cloning it and copy its contents into a new, freshly initialized repository but without the .git folder from the original repository. Afterwards, he simply committed…

1' OR 1 --
- 1,694
- 1
- 16
- 32
4
votes
1 answer
git push patch to remote
is it possible to push a formatted patch directly to remote server without even cloning the repo?
Something like:
git push http://git:mr/android.git master 0001-patch.patch

MTZ4
- 2,274
- 2
- 25
- 41
3
votes
1 answer
git checkout -p with specified encoding
I'm working with the mixed encoding files in a repo.
My system $LANG is en_US.UTF8, file encoding is iso-8859-1. when I run git checkout -p HEAD file git uses UTF8 to show me differences.
And I see something like this:
- "�" - EUR
- …

Yurkee
- 795
- 2
- 9
- 23
3
votes
1 answer
Managing different software versions with git tags across multiple projects
I recently ran into a problem I can't quite solve. Our company among many other projects develops a group of them centered around one - let's call it the engine. The engine contains most of the code base using the MVC framework yii. There are…

Adam Benedek
- 592
- 4
- 17
3
votes
0 answers
Git auto patch submodule
I have a C++ project with a submodule (which I have only read permission).
Early it was just a copy of code instead of submodule. And during the work this copy has been changed a bit.
So, how can I make a auto applying these changes after each…

Denis Lazarev
- 128
- 1
- 9
3
votes
1 answer
Is it possible to set committer to same person who is defined in patch as author when using git am?
Is it possible to set committer to same person who is defined as author in patch when applying patch with git am command?

Kirill
- 6,762
- 4
- 51
- 81
3
votes
1 answer
How to apply git patch on repository with changed history?
Recently i migradted from SVN to git and my team already started to work in fresh git repository.
Later i discovered some problems with conversion and made the 2nd git repo from SVN with some fixes and history rewrites.
Now i have 2nd git copy of…

Kirill
- 6,762
- 4
- 51
- 81
3
votes
1 answer
Ignore space difference in context line when applying git patch
I'm trying to apply patch generated from some git repository. Patch context line looks like this
else if ( o is Item )
and in my code it looks like this
else if (o is Item)
When I apply patch
$ git apply -v --check --directory=myroot…

Soteric
- 3,070
- 5
- 24
- 23
3
votes
3 answers
Git format-patch vs git log -p
I would like to retrieve a list of commits as patches and then try to apply them to another repo in which I stored a very close project to the one from wich I want to retrieve the patch : how can I in one command retrieve all the patches ? what is…

epsilones
- 11,279
- 21
- 61
- 85
2
votes
1 answer
Is it possible to create a git patch from one directory and apply that patch to the different directory ?,
I am trying to create a patch from one directory and apply that patch to the different directory, provided both the directory contains same files.
For Example:
Consider, the repo-1 /local/mnt/workspace/New_version/sample_dir/ contains File1, File2…

Ramdinesh J P
- 139
- 1
- 9
2
votes
1 answer
How to sign off a patch using git
I'm working on a project where some people will sent me git patches and I've to verify those patches and sign off the commits.
We are creating the patches using
git format-patch master --stdout > file.patch
And the file is mailed to us, then we've…

Arun P Johny
- 384,651
- 66
- 527
- 531