DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

The * next to master shows that the branch you are
currently in is still master, but you now have a new
branch named newfeature. Git simply creates a pointer
to the latest commit and uses that commit as the start for
the new branch. Figure 2-12 shows a visual
representation of this change.


Figure 2-12 Adding a Branch


In order to move to the new branch and change your
working directory, you have to use the git checkout
command, which has the following syntax:


Click here to view code image


git checkout [-b] (branchname or commit)

The -b argument is useful for combining the git branch
command with the checkout function and saves a bit of
typing by creating the branch and checking it out
(switching to it) all at the same time. This example
moves Head on your local machine to the new branch, as
shown in Figure 2-13:


Click here to view code image


#git checkout newfeature
Switched to branch 'newfeature'
Free download pdf