Skip to main content

GitKit (Linux Desktop Edition): Learn git and GitHub in Context

Section 3.2 Creating a Feature Branch

When you set out to make changes to the project you will do so by working on a feature branch. The exercises in this section will walk you through the process of creating a feature branch on which you will fix the issue that you claimed in Section 2.4.

Exercises

1.

The git status command provides the current status of your local repository. Use the git status command to see the current status of your local GitKit-FarmData2 repository.
(a)
    What part of the output tells you which branch is currently active in your repository?
  • The branch name is displayed in the first line after "On branch".
  • Correct! The first line specifies the current branch.
  • The branch name is displayed at the end of the second line. It is "origin/main".
  • The second line specifies the origin branch not the active branch.
  • The branch name is not displayed in the output from this git command.
  • Look again, the active branch is listed.
  • The branch name is displayed at the end of the last line. It is "working tree".
  • The last line indicates if there are changes to commit.
Hint.
Look at the first line of the output from the git status command.
(b)
Your output should contain the text “Your branch is up to date with ’origin/main’.” What do you think it means that your branch is “up to date”?
(c)
Your output should contain the text “nothing to commit, working tree clean.” What do you think it means that you have “nothing to commit.” Hint: when would you have something to commit? This is the opposite of that!

2.

The git branch <name> command creates a new branch with the given name. When creating a branch, you should give it a short but descriptive name (e.g. FixTypoInReadme). Note: name may not have spaces, so you can use - (dashes) or CammelCaseText to divide words in your branch names.
(a)
Create a new feature branch with a descriptive name that you will use to fix the issue that you claimed. Remember not to include the < > when writing your own command. Type the command you entered below.
(b)
    Use the git status command again now.
    Creating a new branch with the git branch command makes your new branch the active branch.
  • True.

  • git branch <name> only creates the branch.
  • False.

  • git branch <name> only creates the branch.
Hint.
After you create a branch what needs to be done to make it active?
(c)
How can you tell from the output in Task 3.2.2.b if it switched you to the new branch?
Figure 3.2.1 illustrates the process you just completed to create a feature branch. The feature branch created is shown in orange.
Cloud image of origin, upstream, and local branches.
Figure 3.2.1. Create Feature Branch.
You have attempted of activities on this page.