Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Dave Cohen on
I have a module in drupal.org git. My local copy has 2 commits pending, but I was expecting to see only one. So, I'm curious what's in the other commit that I either forgot to push or who knows what happened.
So, here's what git tells me...
[dave@starbuck fb-3]$ git status
# On branch 6.x-3.x
# Your branch is ahead of 'origin/6.x-3.x' by 2 commits.
#
What I want to know is, what is in each of those commits, before I push them.
What git commands do I need to use?
Comments
Update.... I figured out that
Update....
I figured out that
git diff origin/6.x-3.x
is what might be the answer. However, when I run this, I see only one change to one file (the one commit that I am aware of). What the heck is the second commit that git is telling me about?Here's the one change:
I'm no git master, but from a glance,
It's possible to have made two different commits to one line, that, when run one after the other, result in just one real change.
Even looking at your message, I see something new : the [+-] flag there. I don't recognise it, but it may be that:
You modified that line of text, and committed.
You changed it again and committed.
if you do a diff, you see the difference between what was in the origin repo, and what your version is now - effectively one line changed.
What happened, because git tracks local commits as events, and will forward each event up into the commit log - is there were two commits that happened.
You could even make a change, commit, revert it, commit, and a diff would show "2 commits, 0 changes"
.dan. is the New Zealand Drupal Developer working on Government Web Standards
also
git log
Shows you the commit histiry.
You can
git diff -r d930b7b44339b003931e1eae5adaad6dccd754ab
(copy the hash from the log) to compare your current state against any point in the log, including this phantom commit you are looking for..dan. is the New Zealand Drupal Developer working on Government Web Standards
git show
git show
shows exactly the one commit I expect...Still,
git status
shows 2 commits.git show -n3
(I was mistaken in my earlier post, I misread what
git show
was outputting. It was only showing one commit, but not the one I expected to see.)It turns out,
git show
only shows one commit. There is no option to show all commits (so few options are documented ingit help
), but to show say the last 3 commits, usegit show -n3
.Using that, I was able to find out about my mystery commit...
This may mean something to someone, but certainly not to me. Once again, git has outperformed my feeble intelligence. You win, git.
I try not to hate git, but it is the RCS of distributed version control.
Thanks Dave!
Now I don't feel alone no more...
Thanks to all for all the contributions and efforts here and everywhere else on Drupal.org!
You all rock! ~ dqd (formerly diqidoq)