Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply patch hunk by hunk?

Tags:

git

patch

Is there a way to apply patch from stash hunk by hunk like that as add hunks from working directory into stage: git add -p?

I am looking for similar command:

git stash show -p | git apply --hunk-by-hunk
like image 258
Eugen Konkov Avatar asked Jan 21 '17 10:01

Eugen Konkov


People also ask

What is a Hunk error?

n out of n hunks FAILED - saving rejects to file file.rej. This means that one or more changes, called hunks, could not be introduced into the file. Occasionally this could be because the patch was emailed or copied into a file and whitespace was either added or removed.

What is git hunk?

When you enter Git's patch mode, the chunks of code ('hunks') you're offered to stage/skip can sometimes be bigger than you'd want. Maybe a hunk you're offered contains multiple lines with changes that belong in more than one commit. Luckily, the s option is there to split the hunk down further.

What is git am command?

What is git am ? git am is a super useful command which can be used for many things as it's reading and parsing the mailbox containing the commits you specify and allows you to use only parts of the extracted data such as the code diff, the autor, the message…


1 Answers

AFAIK there is no patch mode for apply. However, you can apply the patch, then interactively remove the hunks (hunk-by-hunk) in the patch you don't like:

git checkout -p

like image 57
jbu Avatar answered Oct 30 '22 02:10

jbu