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 git@git.mycompany.com:myproject.git
To git@git.mycompany.com:m开发者_StackOverflowyproject.git
* [new branch] head -> test/me
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. :)
You can use git push --porcelain.
精彩评论