Skip to content

Latest commit

 

History

History
89 lines (62 loc) · 1.72 KB

tutorial_basic_commands.md

File metadata and controls

89 lines (62 loc) · 1.72 KB

Introduction to Git: a step-by-step guide to your first commit

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.


1. Installing and configuring Git

Installing Git

If you do not have Git installed on your computer, please follow the steps from the setting-up your environment instructions.


Configuring Git

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).


2. Initializing a new Git repository

git init
git init <dir to create>


2. Making a commit

Staging content

git add

# Shortcuts
git add .
git add --all/-A
git add --update/-u

Making a new commit

git commit -m "commit message..."
git commit --am "commit message..."


3. History of a Git repo

git show
git log