While writing the question, and finding What is the difference between "git branch" and "git checkout -b"? in the list of similar questions, I found the answer myself:

$ git checkout -b new_branch_name

I guess I was reading the man page for the wrong command, I was expecting this as 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) were called and then checked out.

Just what I was looking for.

Answer from MvG on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › git › git-checkout-branch
Git Checkout Branch - GeeksforGeeks
February 26, 2026 - ... This method combines the creation ... needing to stop the world. Create and Switch: Use the -b option with git checkout to create and switch to a new branch in one command....
Discussions

git clone and checkout in a single command - Stack Overflow
The following is the command I use to checkout a specific commit. git clone git://repo.git/repo123 git checkout I want to do the above in one step - using a git clone command only... More on stackoverflow.com
🌐 stackoverflow.com
git checkout and merge in one command - Stack Overflow
I just wanted to see if there was ... a single command. ... In the scenario you describe you can do git checkout -B master. It performs a reset instead of a (fast-forward) merge, but that's safe since you did a rebase master first. This solution is also mentioned in an alternative answer to the one you linked to. ... That is a neat idea - saves one step. Thanks. ... Save this answer. ... Show activity on this post. If your branch names are ... More on stackoverflow.com
🌐 stackoverflow.com
If I did a bunch of work and want to move it to another branch while keeping the changes in the original branch too, how do I do it?
A "branch" is just a named pointer to a commit. So what you're trying to do isn't really moving commits between branches, it's moving the branch pointers around. More specifically, you can commit your changes so far to your local main branch, then create another branch pointing to the same place with a command like git branch foobar. Then continue making more commits on the main branch. At that point your commit graph will look something like: origin/main main ↓ ↓ ---*----*----*----*----* ↑ foobar Later, if your change works, you can merge main into the upstream origin/main and delete foobar (which just deletes the pointer, not the commits themselves). You can optionally squash some of the changes together first. If it doesn't work, you can use git reset to move your main pointer back to the foobar "checkpoint", which will discard all of the later changes. Of course, rather than foobar, you should use a meaningful name that reminds you what you created that temporary branch for. More on reddit.com
🌐 r/git
9
4
December 14, 2023
What's the git command to clone a repo and all its branches? I want to make an offline backup of github repository.
git clone already "clones all branches". Normally, a git clone only clones one branch at a time This is simply not true. More on reddit.com
🌐 r/git
13
13
April 21, 2023
🌐
Atlassian
atlassian.com › git › tutorials › using branches › git checkout
Git Checkout | Atlassian Git Tutorial
This page is an examination of the git checkout command. It will cover usage examples and edge cases. In Git terms, a "checkout" is the act of switching between different versions of a target entity. The git checkout command operates upon three distinct entities: files, commits, and branches.
🌐
YouTube
youtube.com › watch
Git Branch Create and Checkout in one Command Example - YouTube
Looking for that one command to create and checkout a Git branch? Well, here's a quick example of how to do exactly that. It's the checkout command with the ...
Published   October 2, 2021
🌐
ShellHacks
shellhacks.com › home › git – create new branch and checkout – in one command
Git - Create New Branch and Checkout - In One Command - ShellHacks
July 4, 2019 - First, you would have to move to develop if you haven’t already. Once you are in develop, you just need to use the commands above to create the new feature branch. In case I haven’t explained myself clear enough, this would be the steps starting in master: git checkout -b develop git checkout ...
🌐
Coderwall
coderwall.com › p › j2nsga › git-checkout-create-branch-in-one-command
Git checkout & create branch in one command (Example)
February 1, 2018 - git checkout -b branch-name · #git · Say Thanks · Respond · 693.9K · 50 · 570.6K · 38 · 552.6K · 0 · Post · Post a tip · Best #Git Authors · filipekiss · 713K · #git · #average at best · khasinski · 601.4K · #git · #Ruby ...
🌐
Jessica Temporal
jtemporal.com › creating-a-new-branch-and-switching-to-it-with-only-one-command
Creating a new branch and switching to it with just one command | Jessica Temporal
June 20, 2026 - To create a new branch and switch to it in one command, you have two options: git checkout -b branch-name or git switch -c branch-name. Both create the branch and move you onto it right away, so you can start committing.
Find elsewhere
🌐
Linux Hint
linuxhint.com › create-branch-and-checkout-using-a-single-command
How to Create Branch and Checkout Using a Single Command – Linux Hint
Then, run the “git checkout -b <branch-name>” command. Another way to generate and redirect to branches is the “git switch -c <branch-name>” command.
🌐
Git
git-scm.com › docs › git-checkout
Git - git-checkout Documentation
Restore a different version of a file, for example with git checkout <commit> <filename> or git checkout <filename> See ARGUMENT DISAMBIGUATION below for how Git decides which one to do. ... Switch to <branch>. This sets the current branch to <branch> and updates the files in your working directory.
🌐
tutorialpedia
tutorialpedia.org › blog › branch-and-checkout-using-a-single-command
How to Create and Switch Git Branches with a Single Command (No More Forgetting 'git checkout') — tutorialpedia.org
For example, a developer might intend to switch branches with git checkout feature/login but accidentally type git checkout -- feature/login, overwriting local changes to a file named feature/login (yikes!).
🌐
Refine
refine.dev › home › blog › alternatives › git switch and git checkout – how to switch branches in git
git switch and git checkout – How to switch branches in git | Refine
July 4, 2025 - To create and switch to a new branch in one command, use git checkout -b new_branch. For remote branches, first fetch the branch using git fetch --all, then switch using git checkout remote_branch_name.
🌐
W3Schools
w3schools.com › git › git_branch.asp
Git Branch
git commit -m "Added image to Hello ... is different from the master branch. Note: Using the -b option on checkout will create a new branch, and move to it, if it does not exist...
🌐
Git Tower
git-tower.com › learn › git faq › git checkout & switch: how to change branches
Git Checkout & Switch: How to Change Branches | Learn Version Control with Git
16 hours ago - # These two are equivalent: $ git checkout -b new-feature $ git switch -c new-feature # These two are equivalent: $ git checkout -f other-branch $ git switch --discard-changes other-branch
🌐
GoLinuxCloud
golinuxcloud.com › home › devops › git › git checkout command explained (branch, commit, file examples)
Git Checkout Command Explained (Branch, Commit, File Examples) | GoLinuxCloud
March 16, 2026 - It updates the HEAD pointer and working directory to match the selected branch or commit. You can switch to an existing branch using git checkout branch-name. To create and switch to a new branch in one command, use git checkout -b new-branch.
🌐
InMotion Hosting
inmotionhosting.com › inmotion hosting home › support › website › git › git checkout command – how to switch to branches and commits
Git Checkout Command - How To Switch To Branches and Commits | InMotion Hosting
February 20, 2025 - Example: git switch -c <new-branch-name> Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 3c05bb0 Added shortcodes file · Once you are done “looking around” ...
🌐
freeCodeCamp
freecodecamp.org › news › git-checkout-explained
Git Checkout Explained: How to Checkout, Change, or Switch a Branch in Git
December 31, 2019 - When you run the following command, Git will ignore unmerged entries: git checkout -f BRANCH-NAME # Alternative git checkout --force BRANCH-NAME
🌐
Git
git-scm.com › book › en › v2 › Git-Branching-Basic-Branching-and-Merging
Git - Basic Branching and Merging
You’ve decided that you’re going to work on issue #53 in whatever issue-tracking system your company uses. To create a new branch and switch to it at the same time, you can run the git checkout command with the -b switch: