Reputation: 6914
A few days ago, I created a new git branch using:
git checkout -b release-1_5
Since creating that new branch, I've made additional changes & commits to it.
I'm the only developer, and no changes have been made to the actual 'master' in the meantime. I want to make the current state of the "release-1_5" branch the new master, and make 'master' the new working (HEAD?) branch, so that if I later do something like:
git checkout -b release-1_6
it will create a new branch that branches off from master
I know I could probably just keep doing "git checkout -b {new-branch-name}" (creating a linear branch-of-a-branch(-of-a-branch[-...]), but I'm pretty sure that would screw up Git's subway-like branch diagram.
If it matters, at the moment, the repo is entirely local, so there's no pulling/pushing or origin to worry about.
Upvotes: 2
Views: 5965
Reputation: 2385
Hope this helps
git checkout release-1_5
git merge --strategy=ours master # This will keep content of branch
git checkout master
git merge release-1_5 # this will fast-forward master to the merge
Upvotes: 1
Reputation: 4596
I would not play with deleting branches.
What you want to do is to simply move latest commit from the release-1_5
to master
.
git checkout master
git merge release-1_5
git checkout master
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.
Upvotes: 1
Reputation: 225262
You're describing a simple merge of release-1_5
back onto master
. Since master
has no new commits, it'll be a fast-forward merge.
$ git checkout master
$ git merge release-1_5
And that's it. You can optionally delete the release-1_5
branch after that if you like.
Upvotes: 5