- Install Git from the official website.
- Create a GitHub account, if you don't have one already.
Open Terminal (or Git Bash if you're on Windows) and type the commands given below to configure it. Enter your information inside the quotation marks.
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
GitHub recently changed the default branch on new repositories from master to main, change the default branch for Git using this command:
git config --global init.defaultBranch main
To verify things are working properly, enter these commands and verify that the output matches your name and email address:
git config --get user.name
git config --get user.email
- Open Terminal.
- Run the following command, replacing the email with your GitHub email address.
ssh-keygen -t ed25519 -C "your_email@example.com"
When prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location (which is~/.ssh/).
- At the prompt, type a secure passphrase (you can press Enter for no passphrase). For more information, see Working with SSH key passphrases.
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
- Copy the SSH public key to your clipboard.
pbcopy < ~/.ssh/id_ed25519.pub
This copies the contents of the id_ed25519.pub file to your clipboard. Make sure the filename you specify in the command matches your SSH public key filename.
- On GitHub, click your profile picture in the upper-right corner, then click Settings.
- In the "Access" section of the sidebar, click SSH and GPG keys.
- Click New SSH key.
- In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".
- Select the type as "Authentication Key".
- In the "Key" field, paste your public key.
- Click Add SSH key.
- If prompted, confirm access to your account on GitHub.
- Open Terminal.
- Run the command:
ssh -T git@github.com
You may see a warning like this:
The authenticity of host 'github.com (IP ADDRESS)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
Are you sure you want to continue connecting (yes/no)?
- Verify that the fingerprint in the message you see matches GitHub's public key fingerprint. If it does, then type yes:
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
- Verify that the resulting message contains your username.
Video: Learn Git In 15 Minutes
Notes: Notion Notes
Video: Learn GitHub in 20 Minutes
Notes: Notion Notes
After learning the basic commands, dive deep into the following:
- Cloning a repo
- Forking a repo
- Difference between cloning and forking
- Difference between origin and upstream
- Branches
- Merge Conflicts
- Pull Requests
Doing this small activity will give you a hands-on experience and help cement your knowledge:
- Fork this very repo.
- Clone it on your local machine.
- Create a new branch <Your_Name>.
- Edit README, add a new line and write, "<Your_Name>: I did it!".
- Commit the changes to your local repo.
- Push the code to your remote repo (the forked one).
- Send a pull request to me so I can accept your changes in this original repo.
Note:
I have included GitHub Education's Git cheat sheet in the repo that contains some commonly used git commands. You can view it here: git-cheatsheet.pdf.
Follow my GitHub profile to stay updated with my latest projects:
- Videos and Notion notes by Colt Steele