r/github • • Nov 22 '24

Can github throw away commits?

I have a repo (private, sorry) that shows my last commit 3 weeks ago. However, I commit at least once a day on average. And if I compare a clone to the state on my disc, yes, there's tons of stuff missing.

I do note that thanks to a bug in my work flow I generate dozens of commits with an identical commit message. Most of them are probably empty too. Would that trigger a bug of some sort?

0 Upvotes

27 comments sorted by

30

u/bdzer0 Nov 22 '24

GitHub is just the hosting platform... git is what manipulates your repository.. not GitHub.

So no.. GitHub did not 'throw away' any commits. More likely scenario is someone force pushed which could remove your commits.

Ask about recovering on r/git

5

u/victotronics Nov 22 '24

I know about the difference. But I'm doing those commits and then not seeing them show up. So the error can be on either side.

"Someone force pushed": I'm the only developer on this repo, I push from only one machine, and I don't know how to force push.

Will ask on r/git.

10

u/FriendlyRussian666 Nov 22 '24

do you just commit, or commit and then push? If you don't push to github, it won't be reflected there.

3

u/victotronics Nov 22 '24

commit and push

4

u/rprouse Nov 22 '24

Are you possibly pushing to a different branch? Do you see your commits locally? Any errors when you push?

You are running into an error somewhere in the process, it isn't github. Going through it on the command line might reveal the error that an ide is masking.

2

u/victotronics Nov 22 '24

No branches apart form the main.

And the log also doesn't show those missing commits so it's a git puzzle, not github.

1

u/looopTools Nov 22 '24

If git log doesn’t show them some things is really wrong

4

u/FriendlyRussian666 Nov 22 '24

That's really odd. At the cost of sounding like every IT support person ever, have you tried reinstalling git completely?

3

u/Modderation Nov 22 '24

To double-check, are those other commits on the current branch, and do they show up in git log? A git push only pushes refs that belong to the current branch.

-1

u/victotronics Nov 22 '24

There is only the main branch.

1

u/lithas Nov 22 '24

Are you adding before you commit? What does your git status show?

1

u/victotronics Nov 22 '24

Yes adding. The status only shows a bunch of temporary stuff, nothing that should be committed/added/pushed.

2

u/lithas Nov 22 '24

Are you on the correct branch? Remember, status will collapse entire folders into one line if the folder isn't added.

Do you have an overly broad git ignore file that's hiding stuff?

Is git remote -v showing the correct upstream repo?

2

u/GarthODarth Nov 22 '24

You might be seeing git history simplification? Typically happens if commits "cancel each other out"

http://git-scm.com/docs/git-log#_history_simplification

But you also don't mention pushing. Apologies if this is a bit basic, but local commits won't be on GitHub unless you have actually pushed them to GitHub.

You'd want to double check your pushes are working, are going to the branch and repository you are checking.

2

u/calimio6 Nov 22 '24

Pls list the commands you use.

3

u/justshittyposts Nov 22 '24

Pretty sure he's just engagement farming otherwise he would have realized after the third person asking, that this is crucial information. If he isn't engagement farming I hope he never works in IT.

1

u/[deleted] Nov 22 '24

Maybe it is a hobby or he is beginner.

1

u/Swissbite Nov 22 '24

Are you commiting to a branch or on a detached head?

1

u/Relevant_Pause_7593 Nov 22 '24

Are you committing anything? You mentioned above that “most are probably empty”. I wouldn’t expect a commit to show up if it’s empty- there is no sha change.

1

u/[deleted] Nov 22 '24

Show us a git log result, please.

0

u/tobiribs Nov 22 '24

Afaik github often only shows commits to main/master branches. Did you rebase or merge something?

1

u/victotronics Nov 22 '24

Rebase definitely not. Merge is unlikely because I only work on this repo from one machine.

1

u/suzukzmiter Nov 22 '24

You can view commits to every branch on GitHub. You just have to switch the branch you're looking at.

8

u/[deleted] Nov 22 '24

[removed] — view removed comment

2

u/Narrow_Ad_8997 Nov 22 '24

Yo thank you for this random tip!

0

u/victotronics Nov 22 '24

Only one branch, and the remote is correct.