The following should do the trick even though you should be aware that there are possibly multiple "children" of a commit (someone else could base work on the PR and merge it into master again later): $ git rev-list -n1 upstream/pull/<number>..upstream/master This works by getting the first commit walking from...