This tutorial provides a guide, step-by-step, overview of some of Git's basic commands. Please go through this material before the start of the course.
If you do not have Git installed on your computer, please follow the steps from the setting-up your environment instructions.
Before we can use Git, we have to perform a minimal configuration setup that consists in setting your user name and email address:
git config --global user.name "First-name Last-name"
git config --global user.email "[email protected]"
# Examples:
git config --global user.name "Alice Smith"
git config --global user.email [email protected]
To see the config values that are currently set, the commands are the following:
git config --get user.name
git config --get user.email
# Show all config values at once and where they are set.
git config --list --show-origin
Optionally you can also change the default editor used by Git, e.g. if you
are more comfortable with nano
than vim
:
git config --global core.editor nano # Set default editor to nano.
git config --global core.editor vim # Set default editor to vim (the default).
git init
git init <dir to create>
git add
# Shortcuts
git add .
git add --all/-A
git add --update/-u
git commit -m "commit message..."
git commit --am "commit message..."
git show
git log