I have a mess in git on 2 branches. Frontend contains a huge chunk of ongoing development work – it should have been fragmented into multiple branches, and it’s a little messed up.
Here is the situation – frontend is on the left, top of master is on the right:
| frontend 1: newest commit (to be pushed)
| frontend 2: recent commit (to be pushed)
| frontend 3: week-old commit (this was a temporary save of lots of ongoing work - it probably should have been a stash. This one cannot be pushed)
|
| | master: this is the current state of the site
| | master: previous commit
| /
|/
| master before `git branch frontend`
On branch frontend, I’d like to:
- transfer
frontend 1andfrontend 2tomasterso they can be pushed now. - ‘cancel’
frontend 3and move the code back to staging so I can make the commits properly (i.e. not in a huge dump of general work)
I am a beginner in git and I am worried I will do more damage (as I have already done) if I keep entering in commands trying to make it better. If you are able to help it would be much appreciated. Thank you.
frontend 3is the newest one.git reset HEAD^to “uncommit” frontend 3 while keeping the changes.git stashto stash the changes fromfrontend 3as you meant tofrontendintomaster. (Or rebase, whichever it is you do.)This assumes that the interactive rebase can in fact be performed cleanly – i.e. that the changes in
frontend 3are unrelated to the ones infrontend 1andfrontend 2.