Switch on another branch (create if not exists), without checking if already exists?
问题 git checkout -b foo switches on foo branch (even if it doesn't exist, it is created), but if the foo branch already exists it throws an error like this: fatal: A branch named 'foo' already exists. What's the command that does the following check? if the branch already exists, just switch on it ( git checkout foo ) if the branch doesn't exist, create it and switch on it ( git checkout -b foo ) 回答1: Update Q3 2019 (Git 2.23): there now actually is a git switch command! git switch -c aBranch You