1.
As you saw in Section 3.2, the
git branch <name>
command creates a branch (among other uses), but it does not change your active branch. The git switch <name>
command switches (i.e. changes) the active branch.(a)
- Switched to branch ’<name>’
- Correct!
- Switched to branch ’main’
- You were on
main
prior to switching branches. -
error: Your local changes to the following files would be overwritten by checkout: ...Aborting
- You should not have made any changes so far.
- fatal: invlalid reference: <name>
- You probably typed the branch name incorrectly. Run
git branch
again to see the name of the branch you created.
Type
git switch <name>
to change your active branch to the new feature branch that you created in the previous section. What output is produced?Hint.
Make sure you don’t include < > in your
git switch <name>
command.(b)
git branch
- Correct!
git status
- Correct!
git log
git log
will show the commit history, it will not show the active branchgit branch <name>
- When
git branch
ends with aname
it creates a new branch, it does not show what is active.
Which of the following commands could be used to confirm that your feature branch is now the active branch?
Hint.
There are two commands that will provide information about the active branch.
(c)
git switch main
- Correct!
git branch main
- This will try to create a new branch named
main
. git branch
git branch
will show all the branchesgit status
git status
will show the active branch and information about changes
Which of the following commands could be used to make
main
the active branch?Hint.
Refer back to how you made your feature branch the active branch.