I am fairly new to Git, having only been using it for the last few months, since taking on a new client (it was what they had been using to manage version control of their software before I started working for them).
I recently merged a development
branch with my local master
branch, and pushed master
to the server. I had tested the site (website written in Django/ Python) on my local development machine prior to pushing it to the server, and it all appeared to be working correctly (including the bug fix that had been implemented on the development
branch).
However, after testing the changes that had been made after pushing to the server, I found that something had broken a part of the site. So I checked out an old commit
on the server, and the live version is now using that old commit
, meaning that it is in a 'Detached HEAD' state, but is functional.
So, my local master
branch is currently the version with the bug fix that I had pushed to the server (which is working locally, but didn't on the server), but since I need to work on another aspect of the site, I want to revert to a backup of master
that I had made prior to merging the development
branch with the bug fix into master
, so that I am developing from the 'most recent working' state of the code.
The branches I have on my machine are:
master
(with development
merged into it, which has broken something else)
masterBackup
(i.e. the master
branch as it was before merging development
into it)
development
(which is the branch on which the original bug has been fixed, but something else is now broken)
So effectively, masterBackup
is actually my working 'master' branch at the moment, since merging development
into master
broke master
. I want to make masterBackup
my 'master' branch again, and master
in its current state can be discarded/ removed. I still have the development
branch, so can look into why/ how this broke the site and fix it there before merging it to master
again.
I found the question at How to replace master branch in git, entirely, from another branch? on which the accepted answer indicates that I should do the following steps:
git checkout masterBackup
git merge -s ours master
git checkout master
git merge masterBackup
But I can't find anything definitive explaining what the command git merge -s ours
does... is this definitely how to make my masterBackup
branch the master
branch again?