0

I cannot find the right answer maybe because I don't know how to make the right question, but I will try to explain myself:

To make a new feature I forgot to make a new branch and I was working and commiting (not pushing) to my local master branch since then. The new feature is not finished yet (and indeed can breaks production), but now I need to do some hotfixes and push them to production (master), so...

Is there any way to checkout/clone another "master" to my local computer and work in there in such a way that I can push the hotfixes changes without pushing the new feature? I know could do it in another computer but is not possible for me now.

thanks in advance

aynber
  • 22,380
  • 8
  • 50
  • 63
aleksdj
  • 145
  • 3
  • 10

2 Answers2

0

Yes, checkout a new branch from where you are, and then reset master.

git checkout -b feature
git checkout master
git reset --hard origin/master
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
0

Find the commit from which you started to make your feature commits. git log master --oneline or git reflog master could help. Assume it's commit xxx.

Rename current master to feature, via git branch -M master feature.

Make a new master from that commit xxx, via git branch master xxx.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53