jeff
jeff

Reputation: 13653

What does `git checkout -b new-feature master` do?

I'm following this tutorial and I'm confused about the fast-forward merge example, where it does the following:

# Start a new feature
git checkout -b new-feature master
# Edit some files
git add <file>
git commit -m "Start a feature"
# Edit some files
git add <file>
git commit -m "Finish a feature"
# Merge in the new-feature branch
git checkout master
git merge new-feature
git branch -d new-feature

What does the second line do? How is it different from git checkout -b new-feature?

Upvotes: 0

Views: 136

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521569

The command

git checkout -b new-feature master

will create a new branch called new-feature master from master and also checkout that new branch.

Check the documentation for more information:

git checkout -b|-B <new_branch> [<start point>]

If the <start point> is omitted, then the current branch is used as the starting point.

Upvotes: 2

Related Questions