Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a List of all Pushes with Git

Tags:

git

How can I get a list of all push commands to or from a particular remote in git?

For my case, this would be OK to run on either the remote or the local repos.

For bonus points, how would I get a list of all successful push commands?

like image 530
Clayton Avatar asked Jan 09 '12 15:01

Clayton


2 Answers

This method will only give you the successful pushes, but it may still be useful to you:

When you push to a branch in a remote that corresponds to one of your remote-tracking branches, and that push is successful, the remote-tracking branch will be updated. In the default case where you've cloned from a repository this typically means that successful pushes to master in the remote origin will update the remote-tracking branch origin/master. Changes to origin/master are recorded in the reflog, so you can find the successful pushes with:

 git reflog show origin/master

For example, in one of my repositories, you'll see:

17f2303 refs/remotes/origin/master@{0}: fetch origin: fast-forward
dd7e0ac refs/remotes/origin/master@{1}: fetch origin: fast-forward
1788ffe refs/remotes/origin/master@{2}: fetch origin: fast-forward
9763bbc refs/remotes/origin/master@{3}: fetch origin: fast-forward
058d0d6 refs/remotes/origin/master@{4}: fetch origin: fast-forward
921f0f1 refs/remotes/origin/master@{5}: fetch origin: fast-forward
8483afd refs/remotes/origin/master@{6}: update by push
18d527f refs/remotes/origin/master@{7}: update by push
1a0fc4a refs/remotes/origin/master@{8}: fetch origin: fast-forward
b19afc6 refs/remotes/origin/master@{9}: fetch origin: fast-forward
9253285 refs/remotes/origin/master@{10}: fetch origin: fast-forward
dfa664f refs/remotes/origin/master@{11}: fetch origin: fast-forward
30ee7c0 refs/remotes/origin/master@{12}: update by push
ad11e76 refs/remotes/origin/master@{13}: fetch origin: fast-forward
c337975 refs/remotes/origin/master@{14}: update by push
1ff03bd refs/remotes/origin/master@{15}: update by push
7fb1c8d refs/remotes/origin/master@{16}: fetch origin: fast-forward
452c8fa refs/remotes/origin/master@{17}: fetch origin: fast-forward
6c79a16 refs/remotes/origin/master@{18}: update by push
11d9c4a refs/remotes/origin/master@{19}: fetch origin: fast-forward

For example, you can tell from this that my most recent push updated origin/master from 18d527f to 8483afd.

If you need to rely on this, you'll need to stop the reflog from expiring after the default time (90 days IIRC).

like image 137
Mark Longair Avatar answered Oct 26 '22 04:10

Mark Longair


Tortoise-Git for Windows has "Show RefLog" option https://tortoisegit.org/docs/tortoisegit/tgit-dug-update.html, which includes date of commit.

like image 37
Michael Freidgeim Avatar answered Oct 26 '22 02:10

Michael Freidgeim