Today I’ve learned a new thing about Git. Actually some days back, we started re-implementation of one of our old web app. Previously, the app was written with Jquery. Some days back, we felt that, it would be better, if we could use ReactJs for the app, as it only shows updates, and each of the updates has it’s own life cycle. So, thought this would be a good use case to leverage the powerful features of ReactJs.
Anyway, as this new development happens to be completely different than the previous one, first decided to create a new repository altogether. But, after some considerations, came to the conclusion, that it would be wrong, if we create a completely new repository for a software, that will do essentially the same things as the previous one.
So, created one orphan branch from master.
git checkout master
And continued development on that.
Until this stage, there was no problem. But, problem started, when we tried to push this branch to master. We could not merge this branch to master, as that would nullify the effort to make a new commit history for the new version.
Decided to delete the master branch and create new master branch from
# Create a backup of the old version
Now, we can’t delete the master branch from remote straight away. It would give the following error.
To [email protected]:username/repo.git
As our repository is hosted in Github, we could change the default branch temporarily to
new_version in the branches tab of settings page of the repository. And delete the
master branch in
git push origin :master
Now, create the new
master branch from
git checkout new_version
Now, change the
default branch to
master in Github.