I was wondering if somebody could explain to me how to GIT merge master into a new branch and then clear out master as to have master clean working directory.
In other words: master -> PHP since master will now have Python.
I was wondering if somebody could explain to me how to GIT merge master into a new branch and then clear out master as to have master clean working directory.
In other words: master -> PHP since master will now have Python.
One solution would be, if nobody has cloned your repo yet, to:
PHP branch where master currently isPython tipSee:
git checkout master
git branch PHP
git checkout Python
git checkout -B master Python
From the checkout man page:
git checkout -b|-B <new_branch> [<start point>]
This form switches branches by updating the index, working tree, and
HEADto reflect the specified branch or commit.If
-Bis given,<new_branch>is created if it doesn’t exist; otherwise, it is reset.This is the transactional equivalent of
$ git branch -f <branch> [<start point>]
$ git checkout <branch>
But if others have cloned your repo, you need to reset the content of master, keeping all the previous commits.
That would be a good case for the non-existent merge -s theirs (where your discard your current content and replace it with the one of another branch, like Python in tour case):
See "git command for making one branch like another" for more.
(and start first by making the PHP branch where master currently is, like above: that bit doesn't change and will mark where PHP updates need to go from now on)
"master" is just a name. It's the default, but there's nothing magical about it.
You could rename your current "master" branch to "PHP" with git branch -m master PHP
Then checkout whatever historic commit you're calling "clean" (use git log to figure that out), and then git branch master to create a master branch at that point.