how to rebase and keep commits in chronological order?

后端 未结 2 753
终归单人心
终归单人心 2021-02-04 08:55

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

2条回答
  •  鱼传尺愫
    2021-02-04 09:06

    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.

提交回复
热议问题