3

Update: this seems to certainly be what I need. However when I follow the intstructions I am stuck as to how I can get my develop branch to point to my temp branch

i.e. How do I execute the following commands in pycharm:

git branch -f develop temp
git checkout master

I was on the "Trying to crop all frames..." commit (commit f4b641d) and I needed to go back to the previous commit temporarily just to look around. I did so with Checkout Revision and then afterwards I went back to commit f4b641 with another checkout revision though I forced it since I didn't care about lost local changes while.

Either way, I now see in the bottom right of the pycharm GUI (see first image) that I am no longer in the develop branch. So I have been developing on the f4b641 branch and now wish to commit and push my changes in this branch back to the develop branch on github. How do I reattatch my head in pycharm without losing my changes?

The warning dialog informs me I should checkout a branch to avoid losing my work, but if I do that I'll lose my local changes wont I?

enter image description here

enter image description here

Community
  • 1
  • 1
Frikster
  • 2,755
  • 5
  • 37
  • 71
  • I'd recommend reading the accepted answer to [this](http://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin) before doing anything. – Harmelodic Mar 17 '16 at 01:16
  • Looks like my reply last night while commuting didn't go through, I tried and am stuck. I have read the link and I am stuck on the "If your new temp branch looks good, you may want to update (e.g.) master to point to it:" How do I get develop to point to temp in pycharm? See updates in question – Frikster Mar 17 '16 at 22:38

2 Answers2

6

Ran into this problem again a year later. Pycharm's UI is insufficient so assuming I've checked out a commit and reset the HEAD there (and I want master to be here) run:

git branch -f master HEAD && git checkout master
Frikster
  • 2,755
  • 5
  • 37
  • 71
  • Awesome... this worked for me, substituting `HEAD` for the branch I was trying to catch up with (ie. `git branch -f master origin/dev && git checkout master`) – StackG Jul 15 '19 at 01:52
0

The problem with detached HEAD in Pycharm can occur due to misconfigured directory mappings. To solve it, go to Preferences -> Version Control. Check that the path to the project directory is correct and remove all other mappings marked in red, if any.