2

i did this

git checkout origin/master
# made some changes
git commit -a -m "test something"

After this i did a git checkout master. Then i got this message

Warning: you are leaving 1 commit behind, not connected to
any of your branches:

  44af060 test something

If you want to keep it by creating a new branch, this may be a good time
to do so with:

 git branch <new-branch-name> 44af060

Switched to branch 'master'
Your branch is up to date with 'origin/master'.

My question is that why this commit does not belong to any branch. I made it on the origin/master head.

2
  • stackoverflow.com/…
    – phd
    Commented May 21, 2020 at 5:43
  • origin/master is not a normal branch. It's a special kind of reference called remote-tracking branch. And though it has "branch" in its name it's actually not. It's not supposed to be used as a branch. When you want to commit you're very much advised to create a normal local branch.
    – phd
    Commented May 21, 2020 at 5:45

1 Answer 1

0

I'm just trying to help.

When you init a repository you are in master/origin branch so if you created another branch you probably need to commit from that branch

You can also reference anywhere you've been by using the reflog:

git reflog

and after that you can that commit

Not the answer you're looking for? Browse other questions tagged or ask your own question.