<p>Sometimes when <a href="/daily/2025/02/11/tidy">tidying my commits</a> or updating a local branch with remote changes, the order of commits changes - making them out of order in when running <code>git log</code>.</p>
<p>I want the commits in the log to be in the correct sequential order.</p>
<p>If not, it would be confusing if I review the commits in the future.</p>
<p>This is easy to fix when running <code>git rebase -i</code> to perform an interactive rebase on the commits.</p>
<p>The commit has a <code>-x</code> or <code>--exec</code> option that will perform a given command on each commit.</p>
<p>The commit date can be reset using <code>git reset --amend</code>, and combining these commands will amend the date of each commit.</p>
<p>Running <code>git rebase --interactive --exec "git commit --amend --no-edit --date now"</code> will amend and update each commit, keeping the commit message the same, but changing the commit date to the current time - leaving the Git log in the correct order.</p>
<p>Sometimes when <a href="/daily/2025/02/11/tidy">tidying my commits</a> or updating a local branch with remote changes, the order of commits changes - making them out of order in when running <code>git log</code>.</p>
<p>I want the commits in the log to be in the correct sequential order.</p>
<p>If not, it would be confusing if I review the commits in the future.</p>
<p>This is easy to fix when running <code>git rebase -i</code> to perform an interactive rebase on the commits.</p>
<p>The commit has a <code>-x</code> or <code>--exec</code> option that will perform a given command on each commit.</p>
<p>The commit date can be reset using <code>git reset --amend</code>, and combining these commands will amend the date of each commit.</p>
<p>Running <code>git rebase --interactive --exec "git commit --amend --no-edit --date now"</code> will amend and update each commit, keeping the commit message the same, but changing the commit date to the current time - leaving the Git log in the correct order.</p>