Reputation: 14929
Branches
Current setup
+-master-+-master--+-master--+
+-staging-+-staging-+-staging-+-staging-+
Make staging as master
What I want to do now is to make staging
as the master
without using git merge
because I am no longer able to keep track of the changes and the position of the heads.
Current branch is staging and I wanted to achieve this
+-master-+-master--+-master--+ +-master-+
+-staging-+-staging-+-staging-+-staging-+
Can the master be overridden by staging using these steps?
git checkout master
git add *
git commit -m "override the master version"
git push -u origin master
Upvotes: 1
Views: 2480
Reputation: 44
I would suggest doing something like this:
git checkout staging
# keep the content of this branch, but record a merge
git merge --strategy = ours master
git checkout master
git merge staging # fast-forward master up to the merge
If you want your history to be a little clearer, I'd recommend adding some information to the merge commit message to make it clear what you've done. Change the second line to:
git merge --strategy=ours --no-commit master
git commit # add information to the template merge message
Upvotes: 1
Reputation: 13238
If I understood your question correctly, you can do
git checkout master
git reset --hard staging
This will make master
point to the same commit as staging
. If your master
has any commits that are not in staging
you will lose them.
Upvotes: 5