1

Environment: On-prem TFS, Git repository

For the past month, we have one specific user that has commits "disappear" from history, along with the actual changes. When I go to the Code view and select the Pushes tab, I see every commit (along with the SHA hash) from this user. If I look at the details of the commit from this view, I can see that it was "Pushed by [user]" and "refs/heads/[branch] udpated from ... to ..." along with diffs. This all seems normal and correct.

When I go to the Commits tab of the same repository and look at the commits for [branch], none of the commits are present from this user starting from a specific date. The user's remote branch tracking seems correct and the commits are definitely getting sent, otherwise they wouldn't show up in the Pushes view. I also cannot find any of these commits using Git Bash with any of the following commands:

$ git branch --contains [short hash]
error: malformed object name [short hash]

$ git branch --contains [full hash]
error: no such commit [full hash]

$ git log -p [short hash]
fatal: ambiguous argument '[short hash]': unknown revision or path not in the working tree

$ git log -p [full hash]
fatal: bad object [full hash]

$ git show [short hash]
fatal: ambiguous argument '[short hash]': unknown revision or path not in the working tree

$ git show [full hash]
fatal: bad object [full hash]

Anyone have any ideas or insight as to what might be going on? I will add any additional details that I can - I just don't know what's relevant at this point.

CodeHxr
  • 855
  • 8
  • 17
  • gc getting in the middle? – eftshift0 Jun 18 '21 at 15:52
  • ```gc getting in the middle?``` for only one user? – CodeHxr Jun 18 '21 at 15:55
  • Different users (different local repos) might have different gc configurations. Perhaps that user has gc configured too aggressively? – eftshift0 Jun 18 '21 at 15:59
  • ```...configured too aggressively?``` Hmmm, alright. It's definitely something I haven't checked yet, so it can't hurt. Would local gc affect commits that are pushed to the remote? – CodeHxr Jun 18 '21 at 16:01
  • Nope... and i would guess the _remote_ itself could have a gc set up too? Say, I mean, the repo where you should see the gc configuration is the one where you were running those commands on. – eftshift0 Jun 18 '21 at 16:09
  • I was running it on my own local repo. I don't think I can run it against TFS's remote. It's just weird that TFS can see these commits as "Pushes", but not as "Commits" and Git Bash can't find them at all. – CodeHxr Jun 18 '21 at 16:12
  • Well.... i don't know how TFS works _but_ if it's stuff from another developer, then those revisions were never on your local _unless_ TFS presents them to you somehow (branches?)... at least from git's POV. – eftshift0 Jun 18 '21 at 16:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/233936/discussion-between-codehxr-and-eftshift0). – CodeHxr Jun 18 '21 at 16:20
  • Hmm... could someone have done an interactive rebase to retroactively remove the commits? If so, how would I detect that? – CodeHxr Jun 21 '21 at 21:33
  • You? From your local repo? You can't... unless you had a branch that pointed in one direction and then the branch remotely points to a different history, then you would know for sure that history was rewritten (git would tell you that there was a forced-push when fetching). – eftshift0 Jun 21 '21 at 21:40

1 Answers1

1

If an interactive rebase was, in fact, done... I'd have no way to tell from my local Git repository, or even the remote repository.
It's still possible, though, that this could've happened and wiped out a month's worth of one developer's commits? (on purpose or not is irrelevant)

No, it should not have wiped out anything. Even if the SHA1 are changed by a rebased, the commits should (unless squashed or dropped by the rebase) be there.

From what I can see in the TFS push API, the Pushes view display push events.
But if, for example, a branch (where those commits were pushed) was deleted (making those commits potentially un-referenced), then you would no longer see them in the visible history of that repository, nor would you be able to fetch them.

Actually, you can try and fetch the last developer's commit SHA1 directly, to see if said commit is still stored (in reflog) by the TFS remote Git repository.
If that works, then you can create a local branch from said fetched commit, and push back that branch: that would make the developer's invisible history visible again.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I'm not in this repository on a day-to-day basis, so is there a way I can tell if a particular branch was, in fact, deleted/recreated? Would it have a different tree ID or something? – CodeHxr Jun 23 '21 at 16:25
  • @CodeHxr Not sure, unless TFS proposes an audit activity log somewhere. – VonC Jun 23 '21 at 16:49
  • 1
    @CodeHxr A branch recreated on the same commit would make those commits visible again, no "branch-id" involved there. My answer is about a branch deleted, branch which was the last object referencing those user's commits: the deletion would make them invisible (present only in the remote TFS reflog, and only for 90 days max) – VonC Jun 23 '21 at 16:51
  • I was able to fetch the missing commit by using your 2nd link: ```git fetch origin [full hash]```. It returned: ```* branch [random hash] -> FETCH_HEAD``` which indicates to me that the branch it was committed to is messed up or deleted. Is that how you interpret the response? (btw: you get the bounty, so thank you!) – CodeHxr Jun 24 '21 at 19:02
  • @CodeHxr Yes, the branch is gone, but since you have fetch its HEAD commit, you can now create a local branch based on it, and push back said local branch, thereby restoring it for all to use. – VonC Jun 24 '21 at 19:52
  • That's exactly what I did. Thank you again for the information! =) – CodeHxr Jun 25 '21 at 20:03