Why Are There Commits on My Branch That I Didn’t Make?

0
11
Asked By CuriousCoder42 On

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

Answered By BranchNinja88 On

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.

Answered By TechSavvyDude On

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.

Answered By CommentMaster3000 On

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!

Answered By CodeExplorer99 On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.