At work I suspect that one person destructively deleted Git history on a repo I created on GitHub, back in February. However, I'm wondering if the same action might be possible without being intentionally destructive?
Here's the situation. Back in February, I created a new repo in our GitHub Organization for some developers, one of them being this person. Our practice, for a few years, has been to call the default branch name main. So, that's what I did, following our precedent. This guy asked me to rename the default branch name to master. I know that historically master is the default branch name for a new Git repo. So, I thought perhaps this guy is just used to doing that. (He's new to our organization and he's a contractor.) So, I acquiesced and renamed the default branch from main to master. Before changing the default branch name, I had made a few commits. I think maybe others on the team may also have made some commits to this new repo. Later I noticed that there was both a main branch, and a master branch, in the repo. I thought it odd, but other demands of my job took my attention.
Today, while working on some GitHub Actions/Workflows in that repo, I noticed some odd behavior. Most of the time I am in the master branch, or some child branch of master. I issued a git switch
into main, just to see what was there. In the GitHub.com interface it looked empty. But after switching to main, Git spent a lot of time fetching files from somewhere, which was very odd. Switching back to master, Git did the same thing. So, then I issued a git log
to get the full history, in the main branch and the master branch. In the main branch I discovered when I created the repo in the first place with those commits I did to the main branch. In the master branch, the first commit was by this contractor some 3 hours later.
I know that it is possible to rewrite git history with a hard reset. I also know you can issue a git push origin --force
, to destroy git history. I suspect this guy did one of those, probably the git push --force
, but before I bring this to anyone else's attention, I'd like to know if it is possible for someone to rewrite Git history "innocently"?
Top comments (0)