3

I've checked out particular commit:

git checkout xx
#made changes
...
git add .
git commit -m "abcd"
git push

But I don't see anything updated back in github site.
Please help me to push successfully to my forked repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
rao
  • 323
  • 1
  • 3
  • 7

1 Answers1

2

You have checkout a commit instead of a branch: you are in a detached HEAD mode, and a git push refuses to push a detached head.
See "Why did my Git repo enter a detached HEAD state?"

detached head

You need to make a new branch based on your current commit, or to reset one existing branch on that commit.
See "git: switch branch without detaching head".

Once your commit is referenced by a branch (as shown by the git branch command), you will be able to push that branch on your remote repo.


Note: with Git 2.23 (August 2019), you can use git restore and update your working tree without detaching HEAD (since you do not switch branch).
To switch branch, you now have (again, Git 2.23) git switch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250