I would like to rebase a branch on the master branch but in such a way that all commits show up in chronological order in the git log. Is this possible without git rebase
If you want to keep the original dates, you are stuck with rebasing according to your dates.
However, if you want to create a pull request and get the commits sorted correctly in a tool that sorts by author date (TFS and GitHub both do), you might want to change the dates instead.
Windows:
git rebase --force-rebase --exec "ping localhost -n 3" --exec "git commit --amend --date=now" master
Linux:
git rebase --force-rebase --exec "sleep 2" --exec "git commit --amend --date=now" master
Note that doing git rebase --ignore-date master does not work, because the date only has second resolution and different commits will get the same date and be sorted in an unspecified order. If you use --exec and --ignore-date together, the --ignore-date parameter will be ignored. Because it is incompatible with interactive mode, which --exec uses.
Your question is a bit underspecified, because git log always sorts its output, but it takes options telling it how to sort:
Commit Ordering
By default, the commits are shown in reverse chronological order.
--date-orderShow no parents before all of its children are shown, but otherwise show commits in the commit timestamp order.
--author-date-orderShow no parents before all of its children are shown, but otherwise show commits in the author timestamp order.
--topo-orderShow no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.
Hence, with no options, git log shows commits in chronological order no matter what.
I think what you're asking is, instead, how you can change the time stamps on the rebased commits. By default, rebase preserves the time stamps.
Note that there are two time stamps on each commit: the author date, and the committer date.
The rebase documentation describes these two options:
--committer-date-is-author-date,--ignore-dateThese flags are passed to
git amto easily change the dates of the rebased commits (see git-am(1)). Incompatible with the--interactiveoption.
Consulting the git am documentation gives a better description of these:
--committer-date-is-author-dateBy default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the committer date by using the same value as the author date.
--ignore-dateBy default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the author date by using the same value as the committer date.
You can see both author and committer dates using the fuller format with git log, for instance (git log --format=fuller).
I believe you want to use --ignore-date, which makes each rebased commit happen "as of right now" (this assumes I'm interpreting your question correctly!).