Skip to content

Latest commit

 

History

History
139 lines (103 loc) · 3.84 KB

basic-workflow.md

File metadata and controls

139 lines (103 loc) · 3.84 KB

Basic workflow commands

git branch

This command lets you manage your branches.

Useful forms

git branch
Lists all your local branches.
git branch -a
Lists local and remote branches.
git branch <branch name>
Create a new branch off the most recent commit.
git branch -d <branch name>
Deletes a local branch.
Assignment 3
  • Create a local branch
  • Verify that the branch has been created by listing your local branches
  • Delete the branch you just created
  • List your local branches and verify the branch has been deleted

git checkout

This command lets you navigate through the different branches in your repo.

Useful forms

git checkout <branch name>
Switches to the specific branch name.
git checkout -b <branch name>
Create a new branch with the specific name and switch to it.
git checkout -b <branch name> <remote name>/<remote branch name>
Create a new branch based on a remote branch and set the upstream of the new branch to the remote branch.
git checkout <remote name>/<branch name>
Switch to the commit pointed to by a remote branch. This will put you in headless mode.
git checkout <commit hash>
Switch to a specific commit hash. This will put you in headless mode.
git checkout <filepath>
Undo all changes done to an unstaged file and revert the content to the most recent commit.
Assignment 4

Create and switch to a new local branch that is based off the remote branch named sequence. Verify you are in the correct branch and that it is linked to a remote branch by using git status.

git add

This command stages modified files for commit or adds untracked files to the next commit.

Useful forms

git add .
Adds all unstaged changes to the next commit.
git add <filepath1> <filepath2> ...
Adds specific files to the next commit.
Assignment 5
  • Modify the sequence.md file and add a new list item.
  • Create a new file called new-file.md and add some random content.
  • Stage only the sequence.md file for commit.

git commit

Adds all staged changes to a new commit with a commit message summary and optional description.

A good commit message summary should be limited to 50 characters and complete the following sentence:

When this commit is applied it will...

Additional information about the change should go into the commit description.

For more guidance, see: How to Write a Git commit message

Useful forms

git commit -m "<commit message>"
Creates a new commit with the specific commit message
git commit
Opens an editor that lets you write a multi-line commit message before creating the new commit.
Assignment 6

Create a new commit with your staged changes and a meaningful commit message.


Next lesson: Commands for working with remote repositories