Skip to content

Instantly share code, notes, and snippets.

@tebajanga
Forked from cmatskas/detached-head-merge.ps1
Created March 30, 2018 08:09
Show Gist options
  • Save tebajanga/ca45a3d3b986ef88e8028aebf956910f to your computer and use it in GitHub Desktop.
Save tebajanga/ca45a3d3b986ef88e8028aebf956910f to your computer and use it in GitHub Desktop.
Git merge detached head
$git checkout –b temp #makes a new branch from current detached HEAD
$git branch –f master temp #update master to point to the new <temp> branch
$git branch –d temp #delete the <temp> branch
$git push origin master #push the re-established history
@tebajanga
Copy link
Author

Slight addition. You would need to switch to a different branch before you can delete the temp branch. So a $ git checkout master should be run before the delete of temp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment