Skip to main content
changed title to reflect its about dealing with a detached head not about detaching a head
Link

Detach Detached head in git

added 132 characters in body
Source Link
mans
  • 17.7k
  • 50
  • 190
  • 338

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

--- update 2 It says thetre are some changes, How can I remove them?

$ git merge origin/master
Updating fb5972a..28c2849
error: The following untracked working tree files would be overwritten by merge:
  ---
Please move or remove them before you can merge.
Aborting

How can I discard them?

These commands did not work:

$ git checkout -- .


$ git stash save --keep-index
No local changes to save

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

--- update 2 It says thetre are some changes, How can I remove them?

$ git merge origin/master
Updating fb5972a..28c2849
error: The following untracked working tree files would be overwritten by merge:
  ---
Please move or remove them before you can merge.
Aborting

How can I discard them?

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

--- update 2 It says thetre are some changes, How can I remove them?

$ git merge origin/master
Updating fb5972a..28c2849
error: The following untracked working tree files would be overwritten by merge:
  ---
Please move or remove them before you can merge.
Aborting

How can I discard them?

These commands did not work:

$ git checkout -- .


$ git stash save --keep-index
No local changes to save
added 329 characters in body
Source Link
mans
  • 17.7k
  • 50
  • 190
  • 338

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

--- update 2 It says thetre are some changes, How can I remove them?

$ git merge origin/master
Updating fb5972a..28c2849
error: The following untracked working tree files would be overwritten by merge:
  ---
Please move or remove them before you can merge.
Aborting

How can I discard them?

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

I have a detached head in git. I am not interested to make any commit or save any changes, I just want to go to the head position of my branch. I have tried his command but it doesn't work:

 git checkout MyBranch

Any help?

---- Update

when I trying to checkout, I am getting this message:

 $ git checkout -f master
 Switched to branch 'master'
 Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.

--- update 2 It says thetre are some changes, How can I remove them?

$ git merge origin/master
Updating fb5972a..28c2849
error: The following untracked working tree files would be overwritten by merge:
  ---
Please move or remove them before you can merge.
Aborting

How can I discard them?

Add some detail
Source Link
mans
  • 17.7k
  • 50
  • 190
  • 338
Loading
Source Link
mans
  • 17.7k
  • 50
  • 190
  • 338
Loading