I'm trying to get the hang of Git and ran into a perplexing issue. I created a new branch, added two commits, and then switched back to the main branch. When I returned to my original branch, I noticed some commits that I didn't create myself. I've already checked with 'git log' and 'git status', and even did some searching online about branches showing extra commits. I think I might have messed up a merge or rebase, but I'm not sure how to determine which one it was. How can I approach figuring this out without just guessing more commands?
4 Answers
When you switched back to your branch, did you do any merging or rebasing with the main branch? Using 'git reflog' can really help you see the history of what you did. If you share the output of that, we might be able to figure out what went down and why those commits are showing up.
It can be tricky to track this down if the details are a bit fuzzy. Git won't randomly create commits; it sounds like you might have accidentally made those commits on the wrong branch. Try checking your terminal history for the commands you've run. That might help clarify what happened.
It might be that you accidentally merged or rebased your branch with main. Take a good look at your commit history to spot where things might have gone awry; this kind of mix-up happens more often than you think!
It's possible someone else made those commits. If you're working in a shared repo, check if anyone else pushed changes. If you're alone, though, you probably made those commits on a different branch and forgot about them.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically