I have a git repo which has a few branches – there’s the master branch, which is our stable working version, and then there is a development/staging branch which we’re doing new work in.
Unfortunately it would appear that without thinking I was a bit overzealous with rebasing and have pulled all of the staging code into Master over a period of time (about 80 commits… yes, I know, stupid, clumsy, poor code-man-ship etc….).
Due to this it makes it very hard for me to do minor fixes on the current version of our app (a rails application) and push out the changes without also pushing out the ‘staged’ new features which we don’t yet want to release.
I am wondering if it is possible to do the following:
- Determine the last ‘trunk’ commit
- Take all commits from that point onward and move them into a separate branch, more or less rolling back the changes
- Start using the branches like they were made for.
Unfortunately, though, I’m still continually learning about git, so I’m a bit confused about what to really do here.
By the way, commits have been pushed to a remote, but I don’t mind re-pushing with –force, I am the only one who pushes remote.
Thanks!
There will be the issue of publication (meaning you will have to:
)
if your situation is:
that is, if your current master its actually also the current stage branch, a simple reset is in order (as knittl mentions in his answer)
But if your situation is:
as in: “I have integrated stage into master, and then go on working on master!”
, then a rebase –onto is in order:
you will get: