1

I am using Git with Flutter and recently I noted that doing a commit I get the message about a Detached Head. I would like to remove the detached head situation.

This was probably generated by the fact that I moved back from version 6.3.1 non-nullable that created some coding issues to a previous "nullable" version.

Then I did some modifications and some commits.

Now I would keep the current version (6.5.0) merging back and removing the detached head status but without going again in the non-nullable version 6.3.1.

How can I do (I use the user interface of Git for Android Studio)?

enter image description here

enter image description here

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • Have you tried merging that loose-ends branch into your current head? There may be conflicts, but hopefully they'll all resolve correctly. – Randal Schwartz Jun 14 '23 at 20:11
  • You could also try rebasing 6.4.2 onto your loose branch. That might also have conflicts, but at least you'd end up with a nice linear history. – Randal Schwartz Jun 14 '23 at 20:12
  • I haven't tried. Which commands should I use to do that? (I am a beginner) – user15690472 Jun 14 '23 at 20:13
  • git checkout 6.5.0 , then git rebase 6.3.1 non nullable, then resolve the conflicts. – Randal Schwartz Jun 14 '23 at 21:11
  • How can I do git rebase 6.3.1 non-nullable? I do not see anything similar in the menu in the picture. Also, I need to pay attention to not restore anything in 6.3.1 non-nullable version since that one was causing issues. Is this action correct? – user15690472 Jun 15 '23 at 06:56
  • I don't know what IDE you're using. I only know the command-line args for this. – Randal Schwartz Jun 15 '23 at 17:26

1 Answers1

0

You may try

git checkout <branch name> 

Or

git checkout -

But you may lose your work. You can try

git checkout -b newbranch

And merge it to the master and use the master branch

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30