-
Notifications
You must be signed in to change notification settings - Fork 1
/
git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow.html
3594 lines (2950 loc) · 192 KB
/
git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!-- saved from url=(0095)http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin -->
<html itemscope="" itemtype="http://schema.org/QAPage"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>git - How can I reconcile detached HEAD with master/origin? - Stack Overflow</title>
<link rel="shortcut icon" href="http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">
<link rel="apple-touch-icon image_src" href="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="http://stackoverflow.com/opensearch.xml">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="stackoverflow.com">
<meta property="og:type" content="website">
<meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded&a">
<meta name="twitter:title" property="og:title" itemprop="title name" content="How can I reconcile detached HEAD with master/origin?">
<meta name="twitter:description" property="og:description" itemprop="description" content="I'm new at the branching complexities of Git. I always work on a single branch and commit changes and then periodically push to my remote origin.
Somewhere recently, I did a reset of some files to...">
<meta property="og:url" content="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin">
<link rel="canonical" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin">
<script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/quant.js.download"></script><script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/beacon.js.download"></script><script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/analytics.js.download"></script><script type="text/javascript" async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/ados.js.download"></script><script src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/jquery.min.js.download"></script>
<script src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/stub.en.js.download"></script>
<link rel="stylesheet" type="text/css" href="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/all.css">
<link rel="alternate" type="application/atom+xml" title="Feed for question 'How can I reconcile detached HEAD with master/origin?'" href="http://stackoverflow.com/feeds/question/5772192">
<meta name="twitter:app:country" content="US">
<meta name="twitter:app:name:iphone" content="Stack Exchange iOS">
<meta name="twitter:app:id:iphone" content="871299723">
<meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin">
<meta name="twitter:app:name:ipad" content="Stack Exchange iOS">
<meta name="twitter:app:id:ipad" content="871299723">
<meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin">
<meta name="twitter:app:name:googleplay" content="Stack Exchange Android">
<meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin">
<meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">
<script>
StackExchange.ready(function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.initSnippetRenderer();
});
StackExchange.using("postValidation", function () {
StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
});
StackExchange.question.init({showAnswerHelp:true,totalCommentCount:6,shownCommentCount:5,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:5772192});
styleCode();
StackExchange.realtime.subscribeToQuestion('1', '5772192');
StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.post-text'); });
});
</script>
<script>
StackExchange.init({"locale":"en","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","serverTime":1479569201,"routeName":"Questions/Show","site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"enableInsertDocLinkDialog":true,"enableSocialMediaInSharePopup":true},"user":{"fkey":"a4a63ee3287cddc7ae476f51615a2116","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true,"ab":{"devstory_onboarding_exp":{"v":"c","g":1},"be_nice_anons_edit":{"v":"b","g":2}}},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}},"story":{"minCompleteBodyLength":75}}, {"site":{"allowImageUploads":true,"enableUserHovercards":true,"styleCode":true,"enableNewLinkInsertDialog":true,"enableImgurHttps":true},"tags":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true},"flags":{"allowRetractingFlags":true},"snippets":{"snippetsEnabled":true,"renderDomain":"stacksnippets.net"},"markdown":{"asteriskIntraWordEmphasis":true}});
StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"a8bdcb712222","js/moderator.en.js":"1e6659dca06d","js/full-anon.en.js":"0e6ca9dc3db0","js/full.en.js":"4b52dfc368bb","js/wmd.en.js":"8788d3738454","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"29ca548cffd4","js/help.en.js":"a56fdf9b9ff2","js/tageditor.en.js":"2178711359dd","js/tageditornew.en.js":"7cdce3b18081","js/inline-tag-editing.en.js":"77dde44800e2","js/revisions.en.js":"2faaeaae2529","js/review.en.js":"314e3cec0a4d","js/tagsuggestions.en.js":"78eee7c19ab2","js/post-validation.en.js":"6b854f4cadcd","js/explore-qlist.en.js":"e71f14781288","js/events.en.js":"bc9d502a39b3","js/keyboard-shortcuts.en.js":"0608da599c37","js/external-editor.en.js":"235e80f649d7","js/external-editor.en.js":"235e80f649d7","js/snippet-javascript.en.js":"8400810c9fc5","js/snippet-javascript-codemirror.en.js":"cd11be23372a"});
StackExchange.using("gps", function() {
StackExchange.gps.init(true);
});
</script>
<script>
StackExchange.ready(function () {
$('#nav-tour').click(function () {
StackExchange.using("gps", function() {
StackExchange.gps.track("aboutpage.click", { aboutclick_location: "headermain" }, true);
});
});
});
</script>
<script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/full-anon.en.js.download"></script><script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/snippet-javascript.en.js.download"></script><script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/post-validation.en.js.download"></script><script async="" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/external-editor.en.js.download"></script></head>
<body class="question-page new-topbar">
<noscript><div id="noscript-padding"></div></noscript>
<script>(function () { var old = $.fn.contents; $.fn.contents = function () { try { return old.apply(this, arguments); } catch (e) { return $([]); } } })()</script>
<iframe id="adzerk-user-match" width="0" height="0" frameborder="0" scrolling="no" onload="window.AUMIframeDone=true" src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/usermatch.html" style="display: none;" marginheight="0" marginwidth="0"></iframe>
<div id="notify-container"></div>
<div id="custom-header"></div>
<div class="topbar">
<div class="topbar-wrapper">
<div class="js-topbar-dialog-corral">
<div class="topbar-dialog siteSwitcher-dialog dno">
<div class="header">
<h3><a href="http://stackoverflow.com/">current community</a>
</h3>
</div>
<div class="modal-content current-site-container">
<ul class="current-site">
<li>
<div class="related-links">
<a href="http://chat.stackoverflow.com/" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a>
</div>
<a href="http://stackoverflow.com/" class="current-site-link site-link js-gps-track" data-id="1" data-gps-track="
site_switcher.click({ item_type:3 })">
<div class="site-icon favicon favicon-stackoverflow" title="Stack Overflow"></div>
Stack Overflow
</a>
</li>
<li class="related-site">
<div class="L-shaped-icon-container">
<span class="L-shaped-icon"></span>
</div>
<a href="http://meta.stackoverflow.com/" class="site-link js-gps-track" data-id="552" data-gps-track="
site.switch({ target_site:552, item_type:3 }),
site_switcher.click({ item_type:4 })">
<div class="site-icon favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>
Meta Stack Overflow
</a>
</li>
</ul>
</div>
<div class="header" id="your-communities-header">
<h3>
your communities </h3>
</div>
<div class="modal-content" id="your-communities-section">
<div class="call-to-login">
<a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=%2fusers%2fstory%2fcurrent&amp;utm_source=stackoverflow.com&amp;utm_medium=dev-story&amp;utm_campaign=signup-redirect" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f5772192%2fhow-can-i-reconcile-detached-head-with-master-origin" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list.
</div>
</div>
<div class="header">
<h3><a href="http://stackexchange.com/sites">more stack exchange communities</a>
</h3>
<a href="http://stackoverflow.blog/" class="fr">company blog</a>
</div>
<div class="modal-content">
<div class="child-content"></div>
</div>
</div>
</div>
<div class="network-items">
<a href="http://stackexchange.com/" class="topbar-icon icon-site-switcher yes-hover js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 162 Stack Exchange sites">
<span class="hidden-text">Stack Exchange</span>
</a>
<a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#" class="topbar-icon icon-inbox yes-hover js-inbox-button" title="Recent inbox messages">
<span class="hidden-text">Inbox</span>
<span class="unread-count" style="display:none"></span>
</a>
<a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#" class="topbar-icon icon-achievements yes-hover js-achievements-button" data-unread-class="" title="Recent achievements: reputation, badges, and privileges earned">
<span class="hidden-text">Reputation and Badges</span>
<span class="unread-count" style="display:none">
</span>
</a>
</div>
<div class="topbar-links">
<div class="links-container">
<span class="topbar-menu-links">
<a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent&utm_source=stackoverflow.com&utm_medium=dev-story&utm_campaign=signup-redirect" class="login-link">sign up</a>
<a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f5772192%2fhow-can-i-reconcile-detached-head-with-master-origin" class="login-link">log in</a>
<a href="http://stackoverflow.com/tour">tour</a>
<a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#" class="icon-help js-help-button" title="Help Center and other resources">
help
<span class="triangle"></span>
</a>
<div class="topbar-dialog help-dialog js-help-dialog dno">
<div class="modal-content">
<ul>
<li>
<a href="http://stackoverflow.com/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">
Tour
<span class="item-summary">
Start here for a quick overview of the site
</span>
</a>
</li>
<li>
<a href="http://stackoverflow.com/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">
Help Center
<span class="item-summary">
Detailed answers to any questions you might have
</span>
</a>
</li>
<li>
<a href="http://meta.stackoverflow.com/" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">
Meta
<span class="item-summary">
Discuss the workings and policies of this site
</span>
</a>
</li>
<li>
<a href="http://stackoverflow.com/company/about" class="js-gps-track" data-gps-track="help_popup.click({ item_type:6 })">
About Us
<span class="item-summary">
Learn more about Stack Overflow the company
</span>
</a>
</li>
<li>
<a href="http://business.stackoverflow.com/?ref=topbar_help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:7 })">
Business
<span class="item-summary">
Learn more about hiring developers or posting ads with us
</span>
</a>
</li>
</ul>
</div>
</div>
</span>
</div>
<div class="search-container">
<form id="search" action="http://stackoverflow.com/search" method="get" autocomplete="off">
<input name="q" type="text" placeholder="Search Q&A" value="" tabindex="1" autocomplete="off" maxlength="240">
</form>
</div>
</div>
</div>
</div>
<script>
StackExchange.ready(function() { StackExchange.topbar.init(); });
</script>
<div class="container">
<div id="header">
<br class="cbt">
<div id="hlogo">
<a href="http://stackoverflow.com/">
Stack Overflow
</a>
</div>
<div id="hmenus">
<div class="nav mainnavs">
<ul>
<li class="youarehere">
<a id="nav-questions" href="http://stackoverflow.com/questions" class="js-gps-track" data-gps-track="top_nav.click({is_current:true, location:3, destination:1})">
Questions
</a>
</li>
<li>
<a id="nav-jobs" href="http://stackoverflow.com/jobs?med=site-ui&ref=jobs-tab" class="js-gps-track" data-gps-track="top_nav.click({is_current:false, location:3, destination:6})">
Jobs
</a>
</li>
<li>
<a id="nav-docs" href="http://stackoverflow.com/documentation" class="js-gps-track" data-gps-track="top_nav.click({is_current:false, location:3, destination:7})">
Documentation
</a>
</li>
<li>
<a id="nav-tags" href="http://stackoverflow.com/tags" class="js-gps-track" data-gps-track="top_nav.click({is_current:false, location:3, destination:2})">
Tags
</a>
</li>
<li>
<a id="nav-users" href="http://stackoverflow.com/users" class="js-gps-track" data-gps-track="top_nav.click({is_current:false, location:3, destination:3})">
Users
</a>
</li>
<li>
<a id="nav-badges" href="http://stackoverflow.com/help/badges" class="js-gps-track" data-gps-track="top_nav.click({is_current:false, location:3, destination:4})">
Badges
</a>
</li>
</ul>
</div>
<div class="nav askquestion">
<ul>
<li>
<a id="nav-askquestion" href="http://stackoverflow.com/questions/ask">Ask Question</a>
</li>
</ul>
</div>
</div>
</div>
<div id="content" class="snippet-hidden">
<div itemscope="" itemtype="http://schema.org/Question">
<link itemprop="image" href="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
<div id="herobox" class="alternate">
<div class="test"></div>
<div id="close">
<a title="click to minimize"><span>x</span> Dismiss</a>
</div>
<div class="content">
<b>Join the Stack Overflow Community</b>
<div class="separator"></div>
<div class="blurb">
Stack Overflow is a community of 6.3 million programmers, just like you, helping each other.
<br>
Join them; it only takes a minute: <br>
</div>
<a href="http://stackoverflow.com/users/signup?ssrc=hero&returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f5772192%2fhow-can-i-reconcile-detached-head-with-master-origin" id="tell-me-more" class="button">Sign up</a>
</div>
</div>
<script>
StackExchange.ready(function () {
var location = 0;
if ($("body").hasClass("questions-page")) {
location = 1;;
} else if ($("body").hasClass("question-page")) {
location = 1;;
} else if ($("body").hasClass("faq-page")) {
location = 5;;
} else if ($("body").hasClass("home-page")) {
location = 3;;
}
$('#tell-me-more').click(function () {
StackExchange.using("gps", function () {
StackExchange.gps.track("hero.action", { hero_action_type: 'cta', location: location }, true);
});
});
$('#herobox #close').click(function () {
StackExchange.using("gps", function () {
StackExchange.gps.track("hero.action", { hero_action_type: "minimize", location: location }, true);
});
$.cookie("hero", "mini", { path: "/", expires: 365 });
$.ajax({
url: "/hero-mini",
success: function (data) {
$("#herobox").fadeOut("fast", function () {
$("#herobox").replaceWith(data);
$("#herobox-mini").fadeIn("fast");
});
}
});
return false;
});
});
</script> <div id="question-header">
<h1 itemprop="name"><a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin" class="question-hyperlink">How can I reconcile detached HEAD with master/origin?</a></h1>
</div>
<div id="mainbar">
<div class="question" data-questionid="5772192" id="question">
<script>
var ados = ados || {}; ados.run = ados.run || [];
ados.run.push(function () { ados_add_placement(22,8277,"adzerk1451923498",4).setZone(43); });
</script>
<table>
<tbody><tr>
<td class="votecell">
<div class="vote">
<input type="hidden" name="_id_" value="5772192">
<a class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>
<span itemprop="upvoteCount" class="vote-count-post ">871</span>
<a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>
<a class="star-off" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#">favorite</a>
<div class="favoritecount"><b>456</b></div>
</div>
</td>
<td class="postcell">
<div>
<div class="post-text" itemprop="text">
<p>I'm new at the branching complexities of Git. I always work on a single branch and commit changes and then periodically push to my remote origin.</p>
<p>Somewhere recently, I did a reset of some files to get them out of commit staging, and later did a <code>rebase -i</code> to get rid of a couple recent local commits. Now I'm in a state I don't quite understand.</p>
<p>In my working area, <code>git log</code> shows exactly what I'd expect-- I'm on the right trail with the commits I didn't want gone, and new ones there, etc.</p>
<p>But I just pushed to the remote repository, and what's there is different-- a couple of the commits I'd killed in the rebase got pushed, and the new ones committed locally aren't there. </p>
<p>I think "master/origin" is detached from HEAD, but I'm not 100% clear on what that means, how to visualize it with the command line tools, and how to fix it.</p>
</div>
<div class="post-taglist">
<a href="http://stackoverflow.com/questions/tagged/git" class="post-tag js-gps-track" title="show questions tagged 'git'" rel="tag">git</a>
</div>
<table class="fw">
<tbody><tr>
<td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/q/5772192" title="short permalink to this question" class="short-link" id="link-post-5772192">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/5772192/edit" class="suggest-edit-post" title="">improve this question</a></div>
</td>
<td align="right" class="post-signature">
<div class="user-info user-hover">
<div class="user-action-time">
<a href="http://stackoverflow.com/posts/5772192/revisions" title="show all edits to this post">edited <span title="2015-06-19 17:49:21Z" class="relativetime">Jun 19 '15 at 17:49</span></a>
</div>
<div class="user-gravatar32">
<a href="http://stackoverflow.com/users/76337/john-saunders"><div class="gravatar-wrapper-32"><img src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/1aa48f7606f5b08595b0a0356a61e8b6" alt="" width="32" height="32"></div></a>
</div>
<div class="user-details">
<a href="http://stackoverflow.com/users/76337/john-saunders">John Saunders</a>
<div class="-flair">
<span class="reputation-score" title="reputation score 138,609" dir="ltr">139k</span><span title="20 gold badges"><span class="badge1"></span><span class="badgecount">20</span></span><span title="179 silver badges"><span class="badge2"></span><span class="badgecount">179</span></span><span title="324 bronze badges"><span class="badge3"></span><span class="badgecount">324</span></span>
</div>
</div>
</div> </td>
<td class="post-signature owner">
<div class="user-info user-hover">
<div class="user-action-time">
asked <span title="2011-04-24 17:51:01Z" class="relativetime">Apr 24 '11 at 17:51</span>
</div>
<div class="user-gravatar32">
<a href="http://stackoverflow.com/users/73297/ben-zotto"><div class="gravatar-wrapper-32"><img src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/ab4250f596ff60b9a1e6ed07036597ca" alt="" width="32" height="32"></div></a>
</div>
<div class="user-details">
<a href="http://stackoverflow.com/users/73297/ben-zotto">Ben Zotto</a>
<div class="-flair">
<span class="reputation-score" title="reputation score 42,619" dir="ltr">42.6k</span><span title="19 gold badges"><span class="badge1"></span><span class="badgecount">19</span></span><span title="110 silver badges"><span class="badge2"></span><span class="badgecount">110</span></span><span title="181 bronze badges"><span class="badge3"></span><span class="badgecount">181</span></span>
</div>
</div>
</div>
</td>
</tr>
</tbody></table>
</div>
</td>
</tr>
<tr>
<td class="votecell"></td>
<td>
<div id="comments-5772192" class="comments ">
<table>
<tbody data-remaining-comments-count="1" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">
<tr id="comment-6612832" class="comment ">
<td>
<table>
<tbody>
<tr>
<td class=" comment-score">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">Have you pushed the commits before the rebase?</span>
– <a href="http://stackoverflow.com/users/526535/manojlds" title="155,993 reputation" class="comment-user">manojlds</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment6612832_5772192"><span title="2011-04-24 18:02:49Z" class="relativetime-clean">Apr 24 '11 at 18:02</span></a></span>
<span class="edited-yes" title="this comment was edited 2 times"></span>
</div>
</td>
</tr>
<tr id="comment-6612979" class="comment ">
<td>
<table>
<tbody>
<tr>
<td class=" comment-score">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">@manojlds: Not sure what you mean. I pushed some time before the rebase, but not immediately before.</span>
– <a href="http://stackoverflow.com/users/73297/ben-zotto" title="42,619 reputation" class="comment-user owner">Ben Zotto</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment6612979_5772192"><span title="2011-04-24 18:18:48Z" class="relativetime-clean">Apr 24 '11 at 18:18</span></a></span>
<span class="edited-yes" title="this comment was edited 1 time"></span>
</div>
</td>
</tr>
<tr id="comment-6613016" class="comment ">
<td>
<table>
<tbody>
<tr>
<td class=" comment-score">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">As in did you previously push the commits that you removed in the rebase -i.. From your answer I think not.</span>
– <a href="http://stackoverflow.com/users/526535/manojlds" title="155,993 reputation" class="comment-user">manojlds</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment6613016_5772192"><span title="2011-04-24 18:22:59Z" class="relativetime-clean">Apr 24 '11 at 18:22</span></a></span>
</div>
</td>
</tr>
<tr id="comment-6613026" class="comment ">
<td>
<table>
<tbody>
<tr>
<td class=" comment-score">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">@manojlds: Correct. I only killed commits that were more recent than the most recent push. (Although as I mentioned, I have since pushed, since I thought everything was OK)</span>
– <a href="http://stackoverflow.com/users/73297/ben-zotto" title="42,619 reputation" class="comment-user owner">Ben Zotto</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment6613026_5772192"><span title="2011-04-24 18:23:44Z" class="relativetime-clean">Apr 24 '11 at 18:23</span></a></span>
</div>
</td>
</tr>
<tr id="comment-6613087" class="comment ">
<td>
<table>
<tbody>
<tr>
<td class=" comment-score">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">Can you explain what you did in <code>I did a reset of some files to get them out of commit staging</code> part? sorry for the questions :)</span>
– <a href="http://stackoverflow.com/users/526535/manojlds" title="155,993 reputation" class="comment-user">manojlds</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment6613087_5772192"><span title="2011-04-24 18:31:58Z" class="relativetime-clean">Apr 24 '11 at 18:31</span></a></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="comments-link-5772192" data-rep="50" data-anon="true">
<a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments."></a><span class="js-link-separator dno"> | </span>
<a class="js-show-link comments-link " title="expand to show all comments on this post" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#" onclick="">show <b>1</b> more comment</a>
</div>
</td>
</tr> </tbody></table>
</div>
<div id="answers">
<a name="tab-top"></a>
<div id="answers-header">
<div class="subheader answers-subheader">
<h2>
16 Answers
<span style="display:none;" itemprop="answerCount">16</span>
</h2>
<div>
<div id="tabs">
<a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin?answertab=active#tab-top" data-nav-xhref="" title="Answers with the latest activity first" data-value="active" data-shortcut="A">
active</a>
<a href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin?answertab=oldest#tab-top" data-nav-xhref="" title="Answers in the order they were provided" data-value="oldest" data-shortcut="O">
oldest</a>
<a class="youarehere" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin?answertab=votes#tab-top" data-nav-xhref="" title="Answers with the highest score first" data-value="votes" data-shortcut="V">
votes</a>
</div>
</div>
</div>
</div>
<a name="5772882"></a>
<div id="answer-5772882" class="answer accepted-answer" data-answerid="5772882" itemscope="" itemtype="http://schema.org/Answer" itemprop="acceptedAnswer">
<table>
<tbody><tr>
<td class="votecell">
<div class="vote">
<input type="hidden" name="_id_" value="5772882">
<a class="vote-up-off" title="This answer is useful">up vote</a>
<span itemprop="upvoteCount" class="vote-count-post high-scored-post">1581</span>
<a class="vote-down-off" title="This answer is not useful">down vote</a>
<span class="vote-accepted-on load-accepted-answer-date" title="loading when this answer was accepted...">accepted</span>
</div>
</td>
<td class="answercell">
<div class="post-text" itemprop="text">
<p>First, let’s clarify <a href="https://git-scm.com/book/tr/v2/Git-Internals-Git-References" rel="nofollow noreferrer">what HEAD is</a> and what it means when it is detached. </p>
<p>HEAD is the symbolic name for the currently checked out commit. When HEAD is not detached (the “normal”<sup>1</sup> situation: you have a branch checked out), HEAD actually points to a branch’s “ref” and the branch points to the commit. HEAD is thus “attached” to a branch. When you make a new commit, the branch that HEAD points to is updated to point to the new commit. HEAD follows automatically since it just points to the branch.</p>
<ul>
<li><code>git symbolic-ref HEAD</code> yields <code>refs/heads/master</code><br>
The branch named “master” is checked out.</li>
<li><code>git rev-parse refs/heads/master</code> yield <code>17a02998078923f2d62811326d130de991d1a95a</code><br>
That commit is the current tip or “head” of the master branch.</li>
<li><code>git rev-parse HEAD</code> also yields <code>17a02998078923f2d62811326d130de991d1a95a</code><br>
This is what it means to be a “symbolic ref”. It points to an object through some other reference.<br>
(Symbolic refs were originally implemented as symbolic links, but later changed to plain files with extra interpretation so that they could be used on platforms that do not have symlinks.)</li>
</ul>
<p>We have <code>HEAD</code> → <code>refs/heads/master</code> → <code>17a02998078923f2d62811326d130de991d1a95a</code></p>
<p>When HEAD is detached, it points directly to a commit—instead of indirectly pointing to one through a branch. You can think of a detached HEAD as being on an unnamed branch. </p>
<ul>
<li><code>git symbolic-ref HEAD</code> fails with <code>fatal: ref HEAD is not a symbolic ref</code></li>
<li><code>git rev-parse HEAD</code> yields <code>17a02998078923f2d62811326d130de991d1a95a</code><br>
Since it is not a symbolic ref, it must point directly to the commit itself.</li>
</ul>
<p>We have <code>HEAD</code> → <code>17a02998078923f2d62811326d130de991d1a95a</code></p>
<p>The important thing to remember with a detached HEAD is that if the commit it points to is otherwise unreferenced (no other ref can reach it), then it will become “dangling” when you checkout some other commit. Eventually, such dangling commits will be pruned through the garbage collection process (by default, they are kept for at least 2 weeks and may be kept longer by being referenced by HEAD’s reflog).</p>
<p><sup>1</sup>
It is perfectly fine to do “normal” work with a detached HEAD, you just have to keep track of what you are doing to avoid having to fish dropped history out of the reflog.</p>
<hr>
<p>The intermediate steps of an interactive rebase are done with a detached HEAD (partially to avoid polluting the active branch’s reflog). If you finish the full rebase operation, it will update your original branch with the cumulative result of the rebase operation and reattach HEAD to the original branch. My guess is that you never fully completed the rebase process; this will leave you with a detached HEAD pointing to the commit that was most recently processed by the rebase operation.</p>
<p>To recover from your situation, you should create a branch that points to the commit currently pointed to by your detached HEAD:</p>
<pre><code>git branch temp
git checkout temp
</code></pre>
<p><sub>(these two commands can be abbreviated as <code>git checkout -b temp</code>)</sub></p>
<p>This will reattach your HEAD to the new <code>temp</code> branch.</p>
<p>Next, you should compare the current commit (and its history) with the normal branch on which you expected to be working:</p>
<pre><code>git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp
git diff master temp
git diff origin/master temp
</code></pre>
<p>(You will probably want to experiment with the log options: add <code>-p</code>, leave off <code>--pretty=…</code> to see the whole log message, etc.)</p>
<p>If your new <code>temp</code> branch looks good, you may want to update (e.g.) <code>master</code> to point to it:</p>
<pre><code>git branch -f master temp
git checkout master
</code></pre>
<p><sub>(these two commands can be abbreviated as <code>git checkout -B master temp</code>)</sub></p>
<p>You can then delete the temporary branch:</p>
<pre><code>git branch -d temp
</code></pre>
<p>Finally, you will probably want to push the reestablished history:</p>
<pre><code>git push origin master
</code></pre>
<p>You may need to add <code>--force</code> to the end of this command to push if the remote branch can not be “fast-forwarded” to the new commit (i.e. you dropped, or rewrote some existing commit, or otherwise rewrote some bit of history).</p>
<p>If you were in the middle of a rebase operation you should probably clean it up. You can check whether a rebase was in process by looking for the directory <code>.git/rebase-merge/</code>. You can manually clean up the in-progress rebase by just deleting that directory (e.g. if you no longer remember the purpose and context of the active rebase operation). Usually you would use <code>git rebase --abort</code>, but that does some extra resetting that you probably want to avoid (it moves HEAD back to the original branch and resets it back to the original commit, which will undo some of the work we did above).</p>
</div>
<table class="fw">
<tbody><tr>
<td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/5772882" title="short permalink to this answer" class="short-link" id="link-post-5772882">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/5772882/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>
<td align="right" class="post-signature">
<div class="user-info user-hover">
<div class="user-action-time">
<a href="http://stackoverflow.com/posts/5772882/revisions" title="show all edits to this post">edited <span title="2016-11-03 16:19:19Z" class="relativetime">Nov 3 at 16:19</span></a>
</div>
<div class="user-gravatar32">
<a href="http://stackoverflow.com/users/2668831/louis-maddox"><div class="gravatar-wrapper-32"><img src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/Lq8l9.jpg" alt="" width="32" height="32"></div></a>
</div>
<div class="user-details">
<a href="http://stackoverflow.com/users/2668831/louis-maddox">Louis Maddox</a>
<div class="-flair">
<span class="reputation-score" title="reputation score " dir="ltr">1,642</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="10 silver badges"><span class="badge2"></span><span class="badgecount">10</span></span><span title="31 bronze badges"><span class="badge3"></span><span class="badgecount">31</span></span>
</div>
</div>
</div> </td>
<td align="right" class="post-signature">
<div class="user-info ">
<div class="user-action-time">
answered <span title="2011-04-24 19:56:33Z" class="relativetime">Apr 24 '11 at 19:56</span>
</div>
<div class="user-gravatar32">
<a href="http://stackoverflow.com/users/193688/chris-johnsen"><div class="gravatar-wrapper-32"><img src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/c8134b3aced69c76a88722e3d36ba034" alt="" width="32" height="32"></div></a>
</div>
<div class="user-details">
<a href="http://stackoverflow.com/users/193688/chris-johnsen">Chris Johnsen</a>
<div class="-flair">
<span class="reputation-score" title="reputation score 101,788" dir="ltr">102k</span><span title="19 gold badges"><span class="badge1"></span><span class="badgecount">19</span></span><span title="146 silver badges"><span class="badge2"></span><span class="badgecount">146</span></span><span title="157 bronze badges"><span class="badge3"></span><span class="badgecount">157</span></span>
</div>
</div>
</div>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td class="votecell"></td>
<td>
<div id="comments-5772882" class="comments ">
<table>
<tbody data-remaining-comments-count="16" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">
<tr id="comment-26334694" class="comment ">
<td class="comment-actions">
<table>
<tbody>
<tr>
<td class=" comment-score">
<span title="number of 'useful comment' votes received" class="warm">5</span>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">Interesting from <code>man git-symbolic-ref</code>: "In the past, <code>.git/HEAD</code> was a symbolic link pointing at <code>refs/heads/master</code>. When we wanted to switch to another branch, we did <code>ln -sf refs/heads/newbranch .git/HEAD</code>, and when we wanted to find out which branch we are on, we did <code>readlink .git/HEAD</code>. But symbolic links are not entirely portable, so they are now deprecated and symbolic refs (as described above) are used by default."</span>
– <a href="http://stackoverflow.com/users/741970/dmitry-minkovsky" title="7,951 reputation" class="comment-user">Dmitry Minkovsky</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment26334694_5772882"><span title="2013-08-02 02:43:56Z" class="relativetime-clean">Aug 2 '13 at 2:43</span></a></span>
<span class="edited-yes" title="this comment was edited 1 time"></span>
</div>
</td>
</tr>
<tr id="comment-37360142" class="comment ">
<td class="comment-actions">
<table>
<tbody>
<tr>
<td class=" comment-score">
<span title="number of 'useful comment' votes received" class="supernova">31</span>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">Awesome. Stuff like this shows that there is room for improvement in git, though. Sometimes while in the middle of project work there is simply no room to waste time with s**t like this and it's simply annoying. But other than that, git is really awesome.</span>
– <a href="http://stackoverflow.com/users/195347/bastiben" title="11,478 reputation" class="comment-user">BastiBen</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment37360142_5772882"><span title="2014-06-13 06:36:24Z" class="relativetime-clean">Jun 13 '14 at 6:36</span></a></span>
</div>
</td>
</tr>
<tr id="comment-46854921" class="comment ">
<td class="comment-actions">
<table>
<tbody>
<tr>
<td class=" comment-score">
<span title="number of 'useful comment' votes received" class="supernova">42</span>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">It is unbelievable how complex versioning systems became</span>
– <a href="http://stackoverflow.com/users/774133/antonio-sesto" title="751 reputation" class="comment-user">Antonio Sesto</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment46854921_5772882"><span title="2015-03-29 18:20:25Z" class="relativetime-clean">Mar 29 '15 at 18:20</span></a></span>
</div>
</td>
</tr>
<tr id="comment-54907306" class="comment ">
<td class="comment-actions">
<table>
<tbody>
<tr>
<td class=" comment-score">
<span title="number of 'useful comment' votes received" class="warm">7</span>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">This is a good answer, but I think there is no need for the temp branch (although I usually use one my self). <code>git branch -f master HEAD && git checkout master</code> is enough -- assuming your goal is to keep your current head but to designate it as <code>master</code>. Other goals also make sense, and call for other recipes.</span>
– <a href="http://stackoverflow.com/users/658298/adrian-ratnapala" title="2,989 reputation" class="comment-user">Adrian Ratnapala</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment54907306_5772882"><span title="2015-11-06 10:28:43Z" class="relativetime-clean">Nov 6 '15 at 10:28</span></a></span>
<span class="edited-yes" title="this comment was edited 3 times"></span>
</div>
</td>
</tr>
<tr id="comment-59516440" class="comment ">
<td class="comment-actions">
<table>
<tbody>
<tr>
<td class=" comment-score">
<span title="number of 'useful comment' votes received" class="warm">5</span>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
<td class="comment-text">
<div style="display: block;" class="comment-body">
<span class="comment-copy">Lol at the comment gurning about length. Whereas the rest of us simply scan through till we reach the line that says "To recover from your situation [...]", and go from there - while making a mental note that there's a useful well-explained backstory that we can read on a rainy day. The <i>option</i> to read more does not hurt you, but it <i>does</i> stand to benefit others.</span>
– <a href="http://stackoverflow.com/users/2757035/underscore-d" title="1,928 reputation" class="comment-user">underscore_d</a>
<span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#comment59516440_5772882"><span title="2016-03-10 22:53:13Z" class="relativetime-clean">Mar 10 at 22:53</span></a></span>
<span class="edited-yes" title="this comment was edited 4 times"></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="comments-link-5772882" data-rep="50" data-anon="true">
<a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."></a><span class="js-link-separator dno"> | </span>
<a class="js-show-link comments-link " title="expand to show all comments on this post" href="http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin#" onclick="">show <b>16</b> more comments</a>
</div>
</td>
</tr> </tbody></table>
</div>
<script>
var ados = ados || {}; ados.run = ados.run || [];
ados.run.push(function () { ados_add_placement(22,8277,"adzerk10821",4).setZone(44); });
</script>
<div class="everyonelovesstackoverflow" id="adzerk10821"></div>
<a name="18866140"></a>
<div id="answer-18866140" class="answer" data-answerid="18866140" itemscope="" itemtype="http://schema.org/Answer">
<table>
<tbody><tr>
<td class="votecell">
<div class="vote">
<input type="hidden" name="_id_" value="18866140">
<a class="vote-up-off" title="This answer is useful">up vote</a>
<span itemprop="upvoteCount" class="vote-count-post ">265</span>
<a class="vote-down-off" title="This answer is not useful">down vote</a>
</div>
</td>
<td class="answercell">
<div class="post-text" itemprop="text">
<p>Just do this:</p>
<pre><code>git checkout master
</code></pre>
<p>Or, if you have changes that you want to keep, do this:</p>
<pre><code>git checkout -b temp
git checkout -B master temp
</code></pre>
</div>
<table class="fw">
<tbody><tr>
<td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/18866140" title="short permalink to this answer" class="short-link" id="link-post-18866140">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/18866140/edit" class="suggest-edit-post" title="">improve this answer</a></div> </td>
<td align="right" class="post-signature">
<div class="user-info ">
<div class="user-action-time">
<a href="http://stackoverflow.com/posts/18866140/revisions" title="show all edits to this post">edited <span title="2016-08-31 06:12:56Z" class="relativetime">Aug 31 at 6:12</span></a>
</div>
<div class="user-gravatar32">
</div>
<div class="user-details">
<div class="-flair">
</div>
</div>
</div> </td>
<td align="right" class="post-signature">
<div class="user-info ">
<div class="user-action-time">
answered <span title="2013-09-18 07:23:00Z" class="relativetime">Sep 18 '13 at 7:23</span>
</div>
<div class="user-gravatar32">
<a href="http://stackoverflow.com/users/34553/daniel-alexiuc"><div class="gravatar-wrapper-32"><img src="./git - How can I reconcile detached HEAD with master_origin_ - Stack Overflow_files/1d876bb038032ede88efaff87c64b97e" alt="" width="32" height="32"></div></a>
</div>
<div class="user-details">
<a href="http://stackoverflow.com/users/34553/daniel-alexiuc">Daniel Alexiuc</a>
<div class="-flair">
<span class="reputation-score" title="reputation score " dir="ltr">6,152</span><span title="8 gold badges"><span class="badge1"></span><span class="badgecount">8</span></span><span title="38 silver badges"><span class="badge2"></span><span class="badgecount">38</span></span><span title="62 bronze badges"><span class="badge3"></span><span class="badgecount">62</span></span>
</div>
</div>
</div>
</td>
</tr>