Search code examples
gitpullsquash

Git: pull doesn't get up-to-date squashed commit


I have to checkout a remote Git branch: foo/bar. This branch had a single commit (made at datetime A) which has been squashed (at datetime B).
Problem: once checked-out, I see the old commit (with datetime A), not the new one.
git pull --force doesn't help me. I also tried to delete my local branche, fetch, check-out, pull.


Solution

  • From the documentation on rewriting history:

    s, squash = use commit, but meld into previous commit

    By default, during an interactive rebase, if you meld the commit messages together during a squash the commit timestamp and author on the original commit (the one you're melding into) are left unchanged. If you want to update these, then select edit instead of pick for the base commit.
    This will then stop the rebase on that commit, giving you the chance to git commit --amend and update meta information about the commit.

    Here's a related answer dealing with modifying the dates of previous commits if you want that information to be updated.