td4u
td4u

Reputation: 454

How to find the files changed in git push by comparing two commit tree and ignoring commits done locally before pushing

I have done a bunch of multiple commits on my local repository and pushed it to the remote repo in github. Now i want to find the files modified by comparing newly pushed commit id and previously pushed commit id. How can i compare it using command?

This command compares the last two commit ids. git diff --name-only HEAD~1 But i want to compare the previous pushed commit ids with the newly pushed commit id. But not the one with multiple commits which i made locally and pushed recently.

I need this for github webhook purpose. Any help is appreciated.

Upvotes: 0

Views: 188

Answers (1)

matt
matt

Reputation: 535231

But i want to compare the previous pushed commit ids with the newly pushed commit id

You can't. There is no such thing, in Git's mind, as "the previously pushed commit". There is absolutely nothing that distinguishes a commit you explicitly pushed from a commit that came along for the ride.

For example, let's say I have this:

A - B - C (mybranch)

And I push mybranch. Now I edit, add, and commit a few more times:

A - B - C - D - E (mybranch)

And I push mybranch again.

Now, you might say I pushed C and E. But, looking at the history, there is nothing that distinguishes C as the commit I previously pushed, or that distinguishes D and E together as the most recent "changes".

The only way to leave that sort of trace while maintaining separate commits is to have your branch consist only of merge commits.

Upvotes: 1

Related Questions