Git basics
Here is a quick refresher on the most important Git command-line basics. These are provided as a reference, not as step-by-step instructions – although we’ve written them so that you can follow along if you want to practice.
First-time setup
First things first: if you’re running Git for the first time on a machine, you may want to set a few global config options.
Set the default branch name to main
:
git config --global init.defaultBranch main
Now configure your default name and email (attached to all of your commits):
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
Now you can initialize a new Git repository.
Initialize a new Git repository
Create a directory and enter it:
mkdir my-repo
cd my-repo
Now tell Git you want to initialize this directory as a new Git repository:
git init
Make and see changes
Create a file with some simple...