Reputation: 46
We have branch structure - master - develop - feature. We created feature from develop and made few changes in the branch. We don't want to merge all changes from branch . Therefore , trying to create the patch.
When i run git format-patch feature/branch-name , it returns empty response. But, when i run git format-patch origin , it returns the list of files missing between develop and master.
I am not sure why git format-patch will return empty response for branch?
Upvotes: 2
Views: 459
Reputation: 1328282
What I am trying to achieve here is create patch for all the changes that are in
feature
and not indevelop
.
That should be:
git switch feature
git format-patch develop --stdout > feature_patches.patch
A simple git format-patch develop
would create separate patch files for each commit.
But in that latter case, you might want to use the new --omit-empty
option.
With Git 2.41 (Q2 2023), "git branch --format=...
"(man) and git format-patch --format=...
(man) learns --omit-empty
to hide refs that whose formatting result becomes an empty string from the output.
See commit aabfdc9 (07 Apr 2023) by Øystein Walle (Osse
).
(Merged by Junio C Hamano -- gitster
-- in commit b64894c, 21 Apr 2023)
branch, for-each-ref, tag
: add option to omit empty linesSigned-off-by: Øystein Walle
If the given format string expands to the empty string, a newline is still printed.
This makes using the output linewise more tedious.
For example,git update-ref
(man)--stdin
does not accept empty lines.Add options to "
git branch
"(man), "git for-each-ref
"(man), and "git tag
"(man) to not print these empty lines.
The default behavior remains the same.
git branch
now includes in its man page:
git for-each-ref
now includes in its man page:
git tag
now includes in its man page:
--omit-empty
Do not print a newline after formatted refs where the format expands to the empty string.
Upvotes: 1