0

In my remote repository I have:

Origin
feature
abc 
20200801_branch_1
20200802_branch_2
.
.
abc 
develop

I want to create a new branch feature/abc/20200811_mybranch with the data from feature/abc/develop. How can I do that??

Thanks!!

1 Answers1

0

Several methods (checkout -b, branch) achieve this simple action with nuances :

1) you currently have feature/abc/develop checked out, you want to create your new branch but stay on feature/abc/develop

git branch feature/abc/20200811_mybranch

2) you currently have feature/abc/develop checked out, you want to create your new branch AND check it out in the same move

git checkout -b feature/abc/20200811_mybranch

3) you have another branch (let's say abc) checked out, you want to create your new branch from feature/abc/develop but stay on your current branch

git branch feature/abc/20200811_mybranch feature/abc/develop

4) you have another branch (let's say abc) checked out, you want to create your new branch from feature/abc/develop AND check out the new branch immediately

git checkout -b feature/abc/20200811_mybranch feature/abc/develop
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • thanks a lot!! I have my branch created locally. I want it to be pushed it to origin, to Github but pushing it does not create the branch in Github. Am I missing something? Thanks again! – Mark Marcel Aug 11 '20 at 11:37
  • What command did you type to push? What message did you get? – Romain Valeri Aug 11 '20 at 11:40
  • I haven't executed it yet: git push feature/abc/20200811_mybranch feature/abc/20200811_mybranch being the first feature/abc/20200811_mybranch on the left the place where I want my local branch to go in Github. Is that correct? – Mark Marcel Aug 11 '20 at 11:46
  • from your local branch, just do `git push origin HEAD` – Romain Valeri Aug 11 '20 at 11:47