Branch and validation using one command

Creating and using a new branch includes two commands:

$ git branch new_branch_name $ git checkout new_branch_name 

I try to forget the last thing that can be annoying. Is there a way to do this using one command? Perhaps using an alias or something similar? I know that I could write a shell function, but for such a simple and general task this works a little.

Bazaar supports this to some extent using the bzr branch --switch .

+4
source share
1 answer

When writing a question and searching for " What is the difference between" <w20> branch "" <w20> checkout -b "? In a list of similar questions, I myself found the answer:

 $ git checkout -b new_branch_name 

I assume I was reading the man page for the wrong command, I expected this to be part of the branch command, not for checkout . Quoting the man page for checkout :

Specifying -b causes a new branch to be created, as if git-branch(1) had been called and then unloaded.

What I was looking for.

+8
source

Source: https://habr.com/ru/post/1494380/


All Articles