This document will help you to setup your computer to use Git & GitHub for your projects.
Download & Install Git for your operating system from https://git-scm.com/downloads
While setting up the installation for Git it is preferable follow the below recommendations:
- For
Choosing the default editor used by Gitselect any GUI based text editor that you are comfortable with - For
Adjusting the name of the initial branch in new repositoriesselectOverride the default branch name for new repositories - For
Configuring the experimental optionscheck bothEnable experimental support for pseudo consolesandEnable experimental built-in file system monitor
Create an account on Github.com
GitHub CLI is GitHub's official open source tool for using GitHub directly from computer's command line & hence provides an easy to use credential system.
- For Windows download GitHub CLI from here or download it using Winget (Preinstalled on Windows):
winget install --id GitHub.cliClose & reopen the terminal window after installation for the command to be available
- For MacOS via Homebrew :
brew install sh- For Linux (Ubuntu & other Debian based distros):
sudo apt install gh- For Linux (Fedora & other RHEL based distros):
sudo dnf install ghAfter installing GitHub CLI, execute the following command to login with your GitHub account
gh auth login- account type: GitHub.com
- preferred protocol: HTTPS
- Authenticate Git with GitHub credentials: Yes
- Authentication method: Login with a web browser
Copy the one-time code provided in the terminal & paste it in the browser window opened for logging in.
🎉 You've successfully connected your GitHub account to Git on your computer. Verify using gh auth status
Execute the following commands with your github account credentials to let git know your username & email
git config --global user.name <YOUR_USERNAME>
git config --global user.email <YOUR_EMAIL>Follow the instructions for your operating system.
For Windows
- Open Git Bash
- Paste below text, with your GitHub email address, for generating a SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"- Accept default choices by pressing enter on prompts
- You've successfully created your SSH key, next add your key to ssh-agent
- Ensure ssh-agent is running by running first line of below text
eval "$(ssh-agent -s)"Agent pid 59566
If you see a similar output, proceed to next step
- Add your SSH private key to ssh-agent
ssh-add ~/.ssh/id_ed25519- Copy public key to your clipboard
clip < ~/.ssh/id_ed25519.pub- Go to GitHub website and click on your profile photo, then click Settings
- In the "Access" section of the sidebar, click SSH and GPG keys
- Click New SSH key or Add SSH key
- In the "Title" field, add a name of your choice for your computer.
- In the "Key field", paste your public key.
- Click Add SSH key
- If prompted, confirm access to GitHub account
- Execute the following code in git bash
ssh -T git@github.com- If a warning pops up, type yes
- You should see a message similar to this, with your username
> Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access
For MacOS
- Open Terminal
- Paste below text, with your GitHub email address, for generating a SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"- Accept default choices by pressing enter on prompts
- You've successfully created your SSH key, next add your key to ssh-agent
- Ensure ssh-agent is running by running first line of below text
eval "$(ssh-agent -s)"
Agent pid 59566
If you see a similar output, proceed to next step
- If using MacOS Sierra 10.12.2 or later, you will need to modify your
~/.ssh/configfile to automatically load keys into the ssh-agent and store passphrases in your keychain.
- First, check if file already exists in the default location
open ~/.ssh/config- If file doesn't exist, create the file
touch ~/.ssh/config- Open the file and modify it to contain the following lines.
Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
- Add your SSH private key to ssh-agent
ssh-add --apple-use-keychain ~/.ssh/id_ed25519- Copy public key to your clipboard
pbcopy < ~/.ssh/id_ed25519.pub- Go to GitHub website and click on your profile photo, then click Settings
- In the "Access" section of the sidebar, click SSH and GPG keys
- Click New SSH key or Add SSH key
- In the "Title" field, add a name of your choice for your computer.
- In the "Key field", paste your public key.
- Click Add SSH key
- If prompted, confirm access to GitHub account
- Execute the following code in terminal
ssh -T git@github.com- If a warning pops up, type yes
- You should see a message similar to this, with your username
> Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access
For Linux
- Open Terminal
- Paste below text, with your GitHub email address, for generating a SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"- Accept default choices by pressing enter on prompts
- You've successfully created your SSH key, next add your key to ssh-agent
- Ensure ssh-agent is running by running first line of below text
eval "$(ssh-agent -s)"Agent pid 59566
If you see a similar output, proceed to next step
- Add your SSH private key to ssh-agent
ssh-add ~/.ssh/id_ed25519- Copy public key to your clipboard
cat ~/.ssh/id_ed25519.pub
# Select & copy the contents of the id_ed25519.pub file
# displayed in the terminal to your clipboard- Go to GitHub website and click on your profile photo, then click Settings
- In the "Access" section of the sidebar, click SSH and GPG keys
- Click New SSH key or Add SSH key
- In the "Title" field, add a name of your choice for your computer.
- In the "Key field", paste your public key.
- Click Add SSH key
- If prompted, confirm access to GitHub account
- Execute the following code in terminal
ssh -T git@github.com- If a warning pops up, type yes
- You should see a message similar to this, with your username
> Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access
Found a mistake or have other improvement for this guide?
Submit a Pull Request!