Useful Commands

Useful Commands#

This is a selection of commands that can particularly enhance your experience with :

git status  

Displays information about:

  • How your current branch compares to its reference branch(es).

  • The status of the workspace:

    • What files have changed and are staged,

    • What files changed and are unstaged.

  • Commands you might want to run.

Note

git status can be particularly useful wenn running a rebase during which you have to step through all rebased commits.

git checkout  

Update the files in the working tree to the specified state. If a branch is provided then HEAD is also updated to point to this branch.

Note

git checkout -b new-branch will create a new branch named new-branch.

git stash  

This command allow you to “put unstaged changes away” such that you can perform operations on your workspace, such as git pull, that would otherwise overwrite files you changed but did not yet add to the stage.

Note

git stash pop will reapply the changes you had put away.

git cherry-pick  

git cherry-pick <commit> will apply the changes introduced in <commit> to the current branch.