What is Git & GitHub? – Prep Guide
🇯🇵 日本語版: 00_Prep.md
This is a guide to get you ready for the Intro to Git & GitHub
lecture.
Here are the steps to do in preparation for the lecture (in order):
- GitHub.com Account
- Visual Studio Code (VS Code) + Command Line
- Install Git
- GitHub Desktop App
- GitHub Command Line (GitHub CLI)
- Configure Git
Outline
- What is Git \& GitHub? – Prep Guide
GitHub.com Account
Step 1 - Create a GitHub.com Account
Create a GitHub.com account by signing up here:
Check out unsplash.com for free images to use for your profile pic:
- unsplash.com/s/photos/cute
- unsplash.com/s/photos/profile-dog
- unsplash.com/collections/410090/animals
Step 2 - Set up Two-Factor Authentication
- Open GitHub.com’s
Two-factor authentication
settings: github.com/settings/security- Click on the
Enable two-factor authentication
button - Select
Set up using an app
option and click theContinue
button
- Click on the
- Scan the QR Code with a two-factor authentication app
- Recommended two-factor authentication apps:
- company smartphone (Recommended!):
- other choices:
- Recommended two-factor authentication apps:
- Enter the 6-digit code from the two-factor authentication app
- Download the recovery codes and click the
I have saved my recovery codes
button - Finally, click the
Done
button
Here is a gif that goes over Step 2:
Resources
- GitHub Help Doc: Configuring two-factor authentication - GitHub Docs
- YouTube: How to setup 2FA with GitHub
Visual Studio Code (VS Code) + Command Line
Install VS Code from here:
Setup the ability to open VS Code from the command line:
- Launch VS Code App
- Open the
Command Palette
with the following shortcut:- Mac:
Command
+Shift
+P
- Windows:
Ctrl
+Shift
+P
- Mac:
- Type
shell
and select theShell Command: Install 'code' command in PATH
option - Restart the Terminal
- In the Terminal, type
code .
to open the current folder in VS Code
Install Git
Install Git for MacOS
-
Install Homebrew (brew.sh) with the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Update and upgrade
brew
before installing new packagesbrew update && brew upgrade
-
Install git with Homebrew
brew install git
-
Confirm the install by checking the git version
git --version # If you see this, you are all set! git version 2.36.1
Debugging
If the following result is returned | git version 1.7.10.2 (Apple Git-33) |
Run this command! | brew link --force git |
Or do this! | export PATH=/usr/local/bin:$PATH |
Now you are ready!
Next section is GitHub Desktop App!
Install Git for Windows 10
- Install git for windows from gitforwindows.org
- Accept the Installation Wizard’s default setting EXCEPT for the following settings:
- For
Choosing the default editor used by Git
setting, select theUse Visual Studio Code as Git's default editor
option - For
Adjusting the name of the initial branch in new repositories
setting, select theOverride the default branch name for new repositories
option - For
Configuring the line ending conversions
setting, select theCheckout as is, commit as is
option - For
Configuring the terminal emulator to use with Git Bash
setting, select theUse Windows's default console window
option - For the last settings page, select the
Launch Git Bash
option and deselect theView Release Notes
option
- For
Screenshots of the Installation Wizard settings
The non-default settings are highlighted.
Now you are ready!
Next section is GitHub Desktop App!
GitHub Desktop App
- Download the GitHub Desktop App from here: desktop.github.com
- Then click the
Sign in to GitHub.com
button - A browser window will launch
- Log into your GitHub.com account by following the screenshots below:
Step 1 | Step 2 | ||
Step 3 | Step 4 | ||
Step 5 | Step 6 |
GitHub Desktop App’s documentation:
- English: GitHub Desktop - GitHub Docs
GitHub Command Line (GitHub CLI)
GitHub CLI for MacOS
-
Update and upgrade brew before installing new packages
brew update && brew upgrade
-
Install GitHub CLI with the following command:
brew install gh
-
Restart the computer before using GitHub CLI
Now you are ready!
Next section is Configure Git!
GitHub CLI for Windows
- Install GitHub CLI by going to cli.github.com and clicking on the
Download for Windows
button - Accept the Installation Wizard’s default setting
- Restart the computer before using GitHub CLI
Now you are ready!
Next section is Configure Git!
Configure Git
Add GitHub.com Login
We will use GitHub CLI’s gh auth login
command to configure the GitHub login
Where to run the commands?
- For Mac users: Use the Terminal for both git commands (
git
) and GitHub CLI commands (gh
) - For Windows users: Use the Command Prompt for both git commands (
git
) and GitHub CLI commands (gh
)
Add GitHub.com login to your computer by going through the following steps:
- Run
gh auth login
command - For
What account do you want to log into?
prompt, selectGitHub.com
option - For
What is your preferred protocol for Git operations?
prompt, selectHTTPS
option - For
Authenticate Git with your GitHub credentials? (Y/n)
prompt, typey
- Copy the 9-character code and hit
enter
- A browser window will launch
- Enter the 9-character code to the GitHub website
- Click the
Authorize
button
Confirm GitHub Authentications were Successful
Confirm settings with the following command: gh auth status
This is what you want to see:
❯ gh auth status
github.com
✓ Logged in to github.com as ahandsel (/Users/***/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
✓ Token: *******************
github.dev.ahandsel.co.jp
✓ Logged in to github.dev.ahandsel.co.jp as ahandsel (/Users/***/.config/gh/hosts.yml)
✓ Git operations for github.dev.ahandsel.co.jp configured to use https protocol.
✓ Token: *******************
Default Branch - main
main
ormaster
is set as the default branch name by git.- The past default is
master
but now it is best-practice to usemain
(given the meaning of the world master 😅)
Use the following command to set the default branch name to main
for your computer.
git config --global init.defaultBranch main
Optional Setups
Windows - Install cash
- Install Node.js on Windows
-
[Download Node.js](https://nodejs.org/en/download/)
-
- Verify Node.js installation by running the following command on Command Prompt
node --version
- Install dthree/cash so you can run Linux commands on Windows Command Prompt
- Install command:
npm install cash-global -g
- Install command:
Next section - Basics and Settings
Go to the Basics & First Repo - 01_Start_EN.md section 💪
List of Lecture Guides
README_EN.md ⚙️