So I've kind of done something a bit unusual. I had a couple of branches, master
and dev
. master
had the latest stable version, and dev
would have the bleeding edge, and would be merged into master
at release.
However, this isn't so good, as a lot of people when they make pull requests, will make it to the master branch. Recently, I had to close a pull request, and ask them to checkout a new branch from the dev branch, and make the changes there, as the dev branch was very far ahead of the master branch, and merging would have been very tricky.
So, I decided to make dev
master
, and make master
stable
.
The first thing I did, with dev
checked out:
git branch -m master stable
Then switch to the new branch:
git checkout stable
Then move dev
to master
:
git branch -m dev master
So, locally I now had two branches, master
(previously dev
) and stable
(previously master
).
I then checked out each branch individually, and ran git push origin <branchname>
for each.
The first problem I noticed, was that even after the push, on the new stable
branch (was master), I get this upon git status
:
# On branch stable
# Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.
#
nothing to commit (working directory clean)
git still thinks that remotely this branch is associated with master
, and because I made dev
into master
, it thinks that stable
is behind. How can I get git to associate this branch with the correct remote one?
The second problem I noticed, on GitHub, branch dev
still exists. How can I remove the remote version?
The third problem, on GitHub, if I select branch master
, below it says latest commit to the dev
branch. Will that change with a few commits? Same goes for the other branch (it says latest commit to master
for stable
).
How can I get the remote fully up-to-date with what is in my local repo?
1) For your first problem, you need set up your branch stable
to track a remote branch origin/stable
git branch --set-upstream stable origin/stable
git branch --set-upstream master origin/master
2) For your second problem, delete remote branch using this git command
git push origin :dev
3) For your third problem, this will be alright after a commit, pull and push.