nohat
nohat

Reputation: 7281

How to get a list of all refs a git push would push?

We're trying to implement a git workflow where there exists a pre-receive hook on the remote repo to validate that all pushed refs have commit messages that contain certain required information. In order to provide some convenience to developers, we'd also like a local git command developers can run to see what all refs would be pushed by a push command so they can verify before pushing whether or not their push would pass the hook, and also create a new git command that calls filter-branch or something else to rewrite all the commit messages to fill in any missing information.

So, is it possible to get a list of everything that would be pushed by a push command? git push --dry-run --verbose only gives a very cursory summary:

For example,

> git push --dry-run --verbose origin head:test/me

Pushing to [email protected]:myproject.git
To [email protected]:myproject.git
 * [new branch]      head -> test/me

Upvotes: 1

Views: 2155

Answers (2)

brahmana
brahmana

Reputation: 1326

git log @{u}..

This will list all the commits that are not yet pushed to the remote. If you want the diff of each commit then add a -p after log

git log -p @{u}..

Yes, the two dots at the end are necessary. :)

Upvotes: 2

mloar
mloar

Reputation: 1554

You can use git push --porcelain.

Upvotes: 0

Related Questions