GitHub's ordering of commits is explained in their "Why are my commits in the wrong order" help page.
-
Create new repo on GitHub
-
Clone locally to /tmp/
$ cd /tmp $ git clone <repo> $ cd <repo>
-
Create branch
$ git co -b testing-order-of-github-commits
-
Add three files
$ touch file1 && git add file1 && git commit -m 'add file1' $ touch file2 && git add file2 && git commit -m 'add file2' $ touch file3 && git add file3 && git commit -m 'add file3'
-
Push the branch to GitHub
$ git push -u origin testing-order-of-github-commits
-
Create a Pull Request from the branch
-
Observe the order of the commits is:
- add file1
- add file2
- add file3
- Rewrite the local branch and change the order of the commits to:
- add file3
- add file1
- add file2
-
Force push the branch to GitHub
$ git push -f origin testing-order-of-github-commits
-
Observe that the order of the commits on GitHub remain unchanged:
- add file1
- add file2
- add file3
I don't think there's any way to use the git
command line client to replicate the order of the commits in GitHub.