Why does git log not show in chronological order, and code has been deleted?

git log examples
git log --pretty
git log - - oneline – graph
git log branch
git log --grep
git log --graph
git show commit changes
git log show files

We are having a strange issue with our git branch that I'm hoping is more about our understanding, than a problem as such. I will describe our workflow the best I can to make sure we're not missing something obvious:

One of the team made a branch with git checkout -b newproject, then made a few changes, then pushed those changes with git push -u origin new project. Then other developers joined the project, using git fetch origin and then git checkout newproject.

Next, the workflow is as follows. Developers make changes, git add the new and modified files, and git commit periodically. Then when they want everyone else to see their changes, they will do a git pull origin newproject to get any changes since the last pull, followed by a git push -u origin newproject.

Note: In /etc/gitconfig we have the following:

[branch]
autosetuprebase = always

Often we'll get conflicts when pulling, as we're working on the same files a lot. When we do, we get the instruction to manually resolve the conflicts then run git rebase --continue We open the files, select the code we want to keep and make necessary changes and save. Then, we git add filename.ext when they're resolved, then run git rebase --continue. After this has finished, with git status showing there are no changes, on the newproject branch and ahead by X commits, we use git push -u origin newproject.

We noticed this morning that large chunks of code suddenly went missing. When running git log, the first thing we noticed was that it wasn't in chronological order, as the manual suggests.

commit bc0903fc5795425908f335cebcab11055869d75d
Author: billy <billy@our.biz>
Date:   Thu Sep 11 15:29:37 2014 +0100

    Add responsive skin to sectionProducts

commit 7833850313c2974c3b8cbc75383b1834fbf4bf93
Author: bob <bob@our.biz>
Date:   Thu Sep 11 14:44:37 2014 +0100

    Rewrite the way breadcrumbs are generated and output to the page

commit 09d1318d9e7249e9e45826d7ddc33f23fc5974b1
Author: bob <bob@our.biz>
Date:   Thu Sep 11 11:25:21 2014 +0100

    Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code

commit 13f01644935092b490be55b6738f500f0f5fcb2e
Author: bob <bob@our.biz>
Date:   Thu Sep 11 08:31:03 2014 +0100

    Fix section.html, add featured products, star buy products and product videos

commit 01b3bfb3c20f74ea437b221711deabc970f670d8
Author: bob <bob@our.biz>
Date:   Fri Sep 12 08:45:19 2014 +0100

    Refine code for breadcrumbs

commit 0303bae79f7ff2e84221e0db3f88d3630d4afa91
Author: bob <bob@our.biz>
Date:   Thu Sep 11 15:53:06 2014 +0100

    Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing

commit 1ae5f00814bf216eda5449a6e8d89123b124fad8
Author: bob <bob@our.biz>
Date:   Thu Sep 11 14:44:37 2014 +0100

    Rewrite the way breadcrumbs are generated and output to the page

It also appears some commits are repeated. Another point to note is that one of the developers mentioned that when they saw some conflicts and resolved them, then ran git rebase --continue, they were shown another list of conflicts. This happened a few times before they were all resolved, before being able to push.

Update: We've noticed that the issues is a little more explainable that initially thought. Right up until, and including, when bob pushed his commits, up to commit 01b3bfb3c20f74ea437b221711deabc970f670d8 with date Fri Sep 12 08:45:19 2014 +0100, everything was correct. It was chronologically ordered and the code was correct. The next 3 commits by bob are in fact the same 3 commits before the commit I just mentioned, and were added when billy pushed his changes. So, they are bob's commits, but somehow re-added by billy. Also notice that the final commit wasn't re-added, which is where the bulk of the problems seem to stem from.

To illustrator this a little better I present the following:

87e9a4e Add sectionGroup.html to templates_safelincs
bc0903f Add responsive skin to sectionProducts
7833850 Rewrite the way breadcrumbs are generated and output to the page
09d1318 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code
13f0164 Fix section.html, add featured products, star buy products and product videos
01b3bfb Refine code for breadcrumbs
0303bae Modify getBreadcrumbTrail so that it attempts to take the correct route when recursing
1ae5f00 Rewrite the way breadcrumbs are generated and output to the page
2cc0525 Fix styles for video and featured product boxes, fix miscellaneous bugs and remove obselete code
cc3c86b Fix section.html, add featured products, star buy products and product videos

Can anyone explain what we're doing wrong here?


For completeness, I'll post the reason here.

Simply put, we were rewriting public history, which is bad. What we do now is rebase from master to our feature branch only, and when it's up to date with our own commits applied at the head, we then merge in to master. We've also started squelching the commits too, actually. Even though we may make the initial commit a few weeks ago.

Git - git-log Documentation, If no --decorate-refs is given, pretend as if all refs were included. Without this flag, git log -p <path> shows commits that touch the specified paths, and Limit the commits output to ones with log message that do not match the pattern was given), the commits are shown in reverse chronological order by commit time. git log -- deletedFile.txt I’ve tried reading through the man page but I’m still not entirely sure what the distinction between using – and not using it is supposed to be. If someone could


I think this sequence will produce the graph you're seeing:

  1. bob pushes three commits not shown, call them a,b,c, whose parent is cc3^
  2. billy pull --rebase's his work on top of them, but decides not to push anything yet
  3. bob for some reason goes back and redoes those three commits, producing cc3, 2cc and 1ae as the new a,b,c, and continues with 030 and 01b.
  4. bob force-pushes this new history, which diverges from billy's at cc3^
  5. billy now pull --rebases again. so a,b,c and two more commits get rebased onto 01b, getting 13f,09d,783 as his newly-rebased versions of Bob's original a,b,c and his own bc0 and 87e.

Viewing the Commit History, The most basic and powerful tool to do this is the git log command. in that repository in reverse chronological order; that is, the most recent commits show up first. As you can see, this command lists each commit with its SHA-1 checksum​, This is very helpful for code review or to quickly browse what happened during a  Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git (and are not ignored by gitignore[5]).


Please see git reflog show command. It helped me recover my local commits.

git-log Documentation, When --show-notes is in effect, the message from the notes as if it is part of the log Do not include refs matching <glob-pattern> that the next --all , --branches was given), the commits are shown in reverse chronological order by commit time. option can be used to tell the command to re-code the commit log message in  Note that git log <file1> <file2> (or gitk <file1> <file2>) is not simply the union of git log <file1> and git log <file2>; it can contain merges which are in neither of the separate histories. Doing the history for two files together is not at all equivalent to doing the history for those files individually and stitching it together.


When was this file added to version control?, By default, running git log will show you all the most recent commits on your branch in reverse chronological order. Meaning, the most These will filter out all commits that do not have a file added, deleted, or modified. git log  $ echo !debug.log >> .gitignore $ cat .gitignore *.log !debug.log $ git add debug.log $ git commit -m "Adding debug.log" This approach is more obvious, and less confusing, for your teammates. Stashing an ignored file. git stash is a powerful Git feature for temporarily shelving and reverting local changes, allowing you to re-apply them later on.


git-log - Show commit logs, --invert-grep Limit the commits output to ones with log message that do not match output may be shown as ref@{Nth} (where Nth is the reverse-chronological index in --date-order Show no parents before all of its children are shown, but this option can be used to tell the command to re-code the commit log message in  If you use such an email for your commits, the commits will not be linked to your GitHub profile and will not show up in your contributions graph.


git-log(1): commit logs, --numstat: Similar to --stat, but shows number of added and deleted lines in decimal Also, when --raw or --numstat has been given, do not munge pathnames and use <format> can be one of short and log. short just shows pairs of commit names, this By default, the commits are shown in reverse chronological order. Instead, they rely on the computer’s clock to some extent. So to fix this iPhone text messages not in chronological order on iOS 11, by far, there is only one way of changing date & time in Settings on iPhone. And here are the steps: Step 1. Go to General > Date & Time > Disable Set Automatically.