New commits not on the head

In short, I did some things with my git repository, which I don’t know how to do, and ended up disconnecting my head, that is, when I committed master, it does not update.

How can i fix this? Should I merge? (If so, which commands do I want to run?)

When I run the git branch, it tells me that I currently do not have a branch

$ git branch
* (no branch)
  master
  • The longer story is that I tried to cancel some commits and had no idea how I should have done it. I guess it wasn’t too long.
+3
source share
4 answers

, ( ), , , . . ( ), , . git -checkout, - git-checkout -m, .

+2

() - , HEAD, , :

git branch temp
git checkout master
git merge temp
git branch -d temp

temp reflog :

git checkout master
git merge HEAD@{1}

HEAD@{1} , ; HEAD@{0} HEAD, , . , HEAD ( ), :

git reflog

, , . mletterle, git reset. git reset --hard rev , , HEAD, . , , , , . git reset rev, , git checkout, , - , .

, git reset . , , , git revert.

+5

. , git reset -hard rev , . http://git-scm.com/docs/git-reset

+1
source

Perhaps you should return to the branch you were working on. If it was a master, it would be

$ git checkout master
0
source

Source: https://habr.com/ru/post/1727555/


All Articles