Page cover

git

This page will have all the things related to git.

git --version

# Configure Git
git config --global user.name "Name"
git config --global user.email "[email protected]"

# if we want to use separate name and mail; initiate a git and then setup new username and mail using the following
git config user.name "Name"
git config user.email "[email protected]"

Git Repository Setup

# Initialize Git in a directory
git init

# Checking current status of git. Displays the state of the working directory and the staging area
git status

# Adding to the staging area
git add <FILE>
git add . (or) git add --all

Git Commit

# Final Commit from the staging area
git commit -m "Added First Files"

Connecting to Github

# Github 
Login > New Repository > Create Repository

# push an existing repository from the command line
git remote add origin <.....>
git branch -M main
git push -u origin main

Github SSH Key Setup

ls -al ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)" # run ssh agent in the background
ssh-add ~/.ssh/id_rsa # adding id_rsa to the ssh-agent
pbcopy < ~/.ssh/id_rsa.pub

# In Github
Settings > SSH and GPG Keys > New SSH Key

Last updated