Vishwavijet N B Vishwavijet N B - 8 months ago 399
Git Question

In GIT how to merge a development branch into master branch by completely overriding the master branch?

My master copy has previous files checked in 2years back. My development branch is up-to date. So i want to update my master branch with development branch.

I tried
git checkout master
git merge -X theirs dev

but it gives an error "can something which we cannot merge"

In the Git web when i tried to create a new pull request, it shows like this "There isn’t anything to compare.
master and master-clean are entirely different commit histories."

Did you mean Origin/Development?


So, gathering the info from all your comments and your OP, you have this situation:

  • A remote (github) repository with a 2-year old, unused, master branch and a current development branch. Let's call this repository origin.
  • You want to get completely rid of the remote master and replace it by the development branch.
  • I assume your local working repository is up-to-date with origin, i.e. you have committed everything you changed in development recently.

So I suggest this procedure:

git checkout development ; git pull        # just in case
git branch master development -f
git checkout master
git push origin master -f

This will:

  • Synchronize your local development branch with the remote one, just in case. After this operation, they should be exactly the same. git status should tell you this clearly.
  • Then you set the master to point to the same commit as development, locally.
  • Then you checkout and push master to the remote, overwriting whatever it was before.

After this, development, master, origin/development, origin/master all point to the same commit, which is whatever your development was beforehand.