Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

O que acontece com um branch desanexado ?

Eu não entendo que acontece com um branch desanexado e o que eu posso fazer com ele ?

Desenvolvimento@DESKTOP-KB3DLRP MINGW64 ~/Documents/treino-git/andre ((bd4ace0...))
$ git status
HEAD detached at bd4ace0
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   index1.html

no changes added to commit (use "git add" and/or "git commit -a")

A hash bd4ace0 virou um novo branch ?

Desenvolvimento@DESKTOP-KB3DLRP MINGW64 ~/Documents/treino-git/andre ((bd4ace0...))
$ git add .

Desenvolvimento@DESKTOP-KB3DLRP MINGW64 ~/Documents/treino-git/andre ((bd4ace0...))
$ git commit -m"Uso do histórico"
[detached HEAD e71db9a] Uso do histórico
 1 file changed, 2 insertions(+), 2 deletions(-)
Desenvolvimento@DESKTOP-KB3DLRP MINGW64 ~/Documents/treino-git/andre ((e71db9a...))
$ git log --oneline

e71db9a (HEAD) Uso do histórico
bd4ace0 Iniciando página
64af31f Alterando o nome
7c5d356 Adicionando a Joice
70cf6ec Adicionando o Andre
6203922 Adicionando ao git-hub
Desenvolvimento@DESKTOP-KB3DLRP MINGW64 ~/Documents/treino-git/andre (master)
$ git checkout e71db9a

Note: switching to 'e71db9a'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at e71db9a Uso do histórico
2 respostas
solução!

Olá André ,

quando vc executa

git checkout e71db9a

vc vai para um commit e qualquer alteração que fizer lá será perdida. A menos que criar um novo branch das alterações de depois realizar o merge com o HEAD. É mais ou menos o que diz aqui

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command.

Excelente resposta Luciano.

Obrigado!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software