I have created a new branch in my project. But what i need now is to back to the Master and create a new branch. How can I do that with git ?
Asked
Active
Viewed 284 times
-2
-
Are you looking for `git checkout master`? – wjandrea Jun 11 '19 at 14:50
-
1`git checkout some-branch`. If you want to create a new branch from another: `git branch new-branch old-branch`. If you would like to create anew branch from another _and checkout_, `git checkout -b new-branch another-branch`. – eftshift0 Jun 11 '19 at 14:51
-
1Possible duplicate of [How to switch back to 'master' with git?](https://stackoverflow.com/questions/7417166/how-to-switch-back-to-master-with-git) – Daan Jun 11 '19 at 14:53
-
@wjandrea no , how can I back to the master (the origin) and then create my new branch from the top – gh.amani Jun 11 '19 at 15:00
2 Answers
2
For example:
git checkout -b new_branch origin/master

Martin G
- 17,357
- 9
- 82
- 98
-
It would probably be helpful if you could explain what this does. This would 1) Create a new branch based on the "master" branch with name "new_branch" and 2) checkout to the new branch. – Daan Jun 11 '19 at 15:00