A Quick Guide to Git & Github

Git & GitHub Basics

GitHub is built to make it easier to use Git for collaboration:

  • Git is an open-source version control tool.
  • GitHub is a platform for hosting and collaborating on Git repositories.

Quick Start

  1. Install Git: Download and install Git from here.
git --version # Check if Git is installed successfully
  1. Configure Git: Link your GitHub account with Git:
git config --global user.name "Your Github User Name"
git config --global user.email "You Github Email"
  1. Configure SSH Keys: To connect your local repository with Github repository
# Execute the following command in Git Bash or Linux/Unix terminal
ssh-keygen -t ed25519 -C "You Github Email"
# Check the generated public key
cat ~/.ssh/id_ed25519.pub
  1. Add SSH Key to GitHub: Copy the content of the public key (Begins with ‘ssh-rsa’) and add it to your GitHub account under Settings > SSH and GPG keys.

Quick Guide to Maintain a Github Repository

  1. Create a new repository on GitHub. Then Clone it to your local machine:
git clone git@github.com:your_username/your_repository.git # First time clone

# or 

git pull # Update your local repository if already cloned
  1. Navigate to your local repository, then do your changes…

  2. Using the following commands to synchronize your local repository with the remote repository on GitHub:

git status # Check the changes you made

git add . # Stage all changes for commit

git commit -am "Your commit message" # Commit the staged changes

git revert HEAD # Undo the last commit (if needed)

git push # Push the committed changes to the remote repository
  1. Using the following command to back to a previous checkpoint:
git log # Check the commit history and find the commit ID you want to back to

git checkout commit_id # Back to the specified commit