1

I'm updating my trello with the last commits pushed on the CI/CD pipeline. For the moment I'm using:

git log --format='- %B' --no-merges HEAD^..HEAD

But it's getting the last commit while I'd like to get a list of all the commits made since the last push.

phd
  • 82,685
  • 13
  • 120
  • 165
javier_domenech
  • 5,995
  • 6
  • 37
  • 59
  • Possible duplicate of [How do I get the ID of the last push in git?](https://stackoverflow.com/questions/9653318/how-do-i-get-the-id-of-the-last-push-in-git) – phd Sep 11 '19 at 11:32
  • https://stackoverflow.com/search?q=%5Bgit%5D+list+commits+since+the+last+push – phd Sep 11 '19 at 11:32

1 Answers1

1

So you'd have to change the reference against which you're comparing the present code.

Your range HEAD^..HEAD is a verbose way to designate HEAD which.... doesn't even need to be designated because it is implied when no ref is explicitly given.

So your command is equivalent to

git log --format='- %B' --no-merges --no-walk

But now for the need to compare against last pushed state : you'd have to use the remote state of the same branch.

Let's assume your branch is called feature-1 and your remote origin :

# First let's make sure the remote ref is up-to-date
git fetch

# then the logging itself
git log --format='- %B' --no-merges origin/feature-1..feature-1
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • this should be done before the pull right? (I'm getting an empty list) – javier_domenech Sep 11 '19 at 10:12
  • Oh, you're right, I forgot to mention! You'd have to `fetch` before you do your logging, to be sure you're comparing against a fresh reference. Editing now. (Don't `pull` instead of `fetch` or else your local and remote refs will be identical and you'll have nothing to compare left.) – Romain Valeri Sep 11 '19 at 10:16