D
D
Denis Petrenko2021-06-19 18:35:43
git
Denis Petrenko, 2021-06-19 18:35:43

How to remove or synchronize HEAD and remote branch on GitLab?

The git picture is as follows:
60ce0de8992dd661014523.png
There is a HEAD that I moved somehow, I couldn’t do it
git push --force, it gave errors about "refs", but now I manually rolled back to the required state and made a commit, but it doesn't let me push again.
Question: how do I now remove everything unnecessary, including HEAD, if I understand correctly, in order to leave the current local version in the origin / main branch on the gitlab servers and on the local?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kuznetsov, 2021-06-20
@Termoslik

A yellow tag means you are not currently on any branch (detached HEAD pointer state). What are you going to push? A branch is needed, which to push. HEAD is not a branch, it's just a pointer to the current state. Here's a good cartoon that will help you understand what's going on.
You need to set your branch pointer to the current commit pointed to by HEAD . The case of the -B option is important here, since a branch with that name already exists somewhere and we are forcibly recreating it in a new place. And being in the branch, we can already push it.
git checkout -B имя_твоей_ветки HEAD

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question