I'm working in a source tree and I went and reverted back to a checkout on a commit and now it's generated a new head or branch so when I push to the server it's not working to push to the master because it's a new head. How do I make my last recent commit become the new master in source tree and continue on being able to push to the server.
Asked
Active
Viewed 269 times
0
-
Probably you can `push --force` but remember: with great power comes great responsibility – gioaudino Jan 23 '20 at 22:01
-
I'm using a gui interface how do I make the head branch go back to being master, that option in the gui is disable to use --force gioaudino – ONYX Jan 23 '20 at 22:03
-
You can enable the force push from the Options menu. Be aware that force pushing will overwrite the history of the remote master branch with whatever you're pushing. There's no way back – gioaudino Jan 23 '20 at 22:07
-
Does this answer your question? [Cannot push to GitHub - keeps saying need merge](https://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge) – phd Jan 23 '20 at 22:14
-
https://stackoverflow.com/search?q=%5Bgit%5D+push+after+reset – phd Jan 23 '20 at 22:14
-
1Can you provide more information about the current state of your repository and what you would like to do from here? Diagrams or screenshots of your repo will help us understand better what the problem is. – Code-Apprentice Jan 23 '20 at 22:20
-
1I don't know why everyone is suggesting the highly advanced and dangerous `push -f`, when I think all they need is to do a `git pull` followed by a `git push` – JoelFan Jan 23 '20 at 22:22
-
Please don't suggest force pushing without **clearly** expressing what will happen and first exploring **why** there is a new head and what are the other alternatives! You do **not** want to be on the receiving end of someone who doesn't know what they're doing eradicates history on the server repeatedly because strangers on Stack Overflow said it was OK to shoot off your foot. – Lasse V. Karlsen Jan 24 '20 at 11:30
1 Answers
0
detached head means that you are no longer in a branch but you have checked-out a specific commit. To continue to work from there just create a new branch.
git checkout -b my_new_branch
or if you are using sourcetree only -> right click on your current position in history tab -> branch.
I strongly advise you to become familiar with git commands and execute them in a console instead of relying on sourcetree for this. It will pay off for sure!
Now that being said, sourcetree is an excellent tool for reviewing repository changes!

yanislavgalyov
- 161
- 9