Duong Nguyen
Duong Nguyen

Reputation: 1

How can I extract filepaths and changes from a commit or pull request using git?

I'm trying to get a consolidated list of changes (file paths and new/modified/deleted changes) from a commit/pull request in Github.

This is the format I'm trying to aim for:

filepath/to/some/file.properties:thisIsAKey=This is the string for this key.

I'm able to grab filepaths relatively easily using:

git show --pretty="format:" --name-only commitID

I also tried this but it includes a lot of noise:

git log -p commitID

Here's what I have from using the above, but I only need the b/+ changes:

diff --git a/locales/ES/es/forms/dispute-options.properties b/locales/ES/es/forms/dispute-options.properties
index 490457e9e0..569921196a 100644
--- a/locales/ES/es/forms/dispute-options.properties
+++ b/locales/ES/es/forms/dispute-options.properties
@@ -60,4 +60,5 @@ fraudSeller.info=Para cancelar este pedido tendrá que comunicarse directamente
 fraudSeller.errorHeadingMessage = Lo sentimos, pero no puede reportar este tipo de problema para la transacción seleccionada.
 fraudSeller.backButtonText = Atrás

-modal.cancel=Cancel
\ No newline at end of file
+modal.cancel=Cancel
+disputeOptions.creditTransactionInfo=Si presenta un caso para esta compra, aún tendrá que continuar pagando cualquier saldo importe dejado en su plan de {data.pageStore.value.creditProductDescriptor} junto con la comisiones tardía (si corresponde).

I've been reading the documentation on how to use diff-filter, but haven't seen anything that matches what I need yet.

Edit: Thanks for everyone's comments! It led me to the answer I was looking for: git diff -U0 --ignore-all-space commitID1 commitID2 | grep '^[+]' | grep -Ev '^(--- a/)' > test.txt

Upvotes: 0

Views: 681

Answers (1)

eftshift0
eftshift0

Reputation: 30297

Given that you are talking about PRs (which can mean many revisions, not just one), I think you have to try:

git diff --name-only base-branch...pr-branch

notice the triple dot

That should give you the list of added/deleted/modified files.

Upvotes: 1

Related Questions