Skip to main content
Rollback to Revision 14
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp

Eventually, remove the temp branch (if you created one):

git branch -d temp

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp

Eventually, remove the temp branch (if you created one):

git branch -d temp

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp
Added command to remove temp branch
Source Link
Sudhanshu Mishra
  • 6.7k
  • 2
  • 62
  • 77

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp

Eventually, remove the temp branch (if you created one):

git branch -d temp

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp

Eventually, remove the temp branch (if you created one):

git branch -d temp
an equivalent, but shorter, command
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git branchcheckout -fB master temp
git checkout master

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git branch -f master temp
git checkout master

Just do this:

git checkout master

Or, if you have changes that you want to keep, do this:

git checkout -b temp
git checkout -B master temp
improved grammar
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
Explain how to keep changes.
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
Rollback to Revision 2
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
added warning.
Source Link
Loading
Rollback to Revision 2
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
document and explain dangerous command
Source Link
Cees Timmerman
  • 19k
  • 11
  • 95
  • 129
Loading
Rollback to Revision 2
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
Rollback to Revision 3
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
missing information
Source Link
kenorb
  • 162.6k
  • 93
  • 697
  • 763
Loading
grammar (also I accidently downvoted this answer and can't upvote it)
Source Link
Loading
added alternative case for another detached head scenario
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading
Source Link
Daniel Alexiuc
  • 13.2k
  • 9
  • 59
  • 73
Loading