Reading12 min read·Module 1
Your first commit, screen by screen
Git keeps every version of your project. You can see what changed and when, go back to any earlier version, and work alongside other people without overwriting each other's work. In the next twelve minutes you'll make a repository and two commits, and read every screen Git shows you on the way.
Open a terminal.
1. Check that Git is installed
git --version
Tap the picture to enlarge it.
- Your Git version. This course uses commands from Git 2.23 and later, so update if yours is older.
If the command isn't found, install Git first:
Run git --version once more. The first time, macOS offers to install its command line developer tools, which include Git: click Install, then run it again.
2. Tell Git who you are
Use your own name and email:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
git config --global --list
Tap the picture to enlarge it.
- Your name and email go on every commit you make. Use the email your GitHub account has, and GitHub links your commits to you. The third setting names the first branch of every new repository
main. --listshows what you saved.--globalkeeps it in one file for every repository on this computer.
Git 3.0 will make main the default branch name. Until then, that third line does it.
3. Make a repository
mkdir notes && cd notes
git init
Tap the picture to enlarge it.
- A new folder for the project, and you step into it.
git initmakes the folder a repository. Everything Git knows about the project lives in the hidden.gitfolder inside it.
1 / 4