0% found this document useful (0 votes)
3 views1 page

SOP For git&GitHUB

This document provides a comprehensive guide on generating and setting up SSH keys for GitHub, including testing the SSH connection. It also details the steps for creating a Personal Access Token (PAT) and using it with HTTPS Git commands, along with common Git CLI commands for managing repositories. Additionally, it explains how to create and push directories and files within a branch in Git.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

SOP For git&GitHUB

This document provides a comprehensive guide on generating and setting up SSH keys for GitHub, including testing the SSH connection. It also details the steps for creating a Personal Access Token (PAT) and using it with HTTPS Git commands, along with common Git CLI commands for managing repositories. Additionally, it explains how to create and push directories and files within a branch in Git.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

# SSH key generation and setup

ssh-keygen -t rsa -b 4096 -C "[email protected]" # Generate SSH key pair


cat ~/.ssh/id_rsa.pub # View and copy your SSH public key
# Add this key to GitHub SSH keys at https://github.com/settings/keys
ssh -T [email protected] # Test SSH connection to GitHub

# Personal Access Token (PAT) generation (manual steps on GitHub website)


# 1. Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens
(classic)
# 2. Generate new token with required scopes (e.g., repo)
# 3. Copy the token (you won't see it again)

# Using PAT with HTTPS Git commands


git clone https://github.com/username/repository.git # Clone repo using HTTPS URL
# When prompted for username, enter GitHub username
# When prompted for password, enter your Personal Access Token (PAT)

# Git CLI common commands


nano filename.txt # Open a file with nano editor
git add . # Stage all changes in current directory
git commit -m "Fix post-merge issues" # Commit changes with message
git push origin branchname # Push branch to remote origin
git push -u origin branchname # Push and set upstream tracking for branch
git branch branchname # Create a new branch
git branch -d branchname # Delete a branch locally
git checkout branchname # Switch to a branch
git log --oneline --graph --decorate -5 # View last 5 commits graphically

# Explanation of git log switches:


# --oneline: Shows each commit in a single line summary
# --graph: Displays an ASCII graph of the branch and merge history
# --decorate: Adds branch names, tags, and refs to the commits displayed

git pull origin branchname # Pull latest changes from remote branch

# Explanation of terms:
# origin: Default name for the remote repository (usually GitHub repo URL)
# main: Default primary branch in the repository (used to be 'master')

# Creating and pushing a directory in a branch:


mkdir new_directory # Create a new directory in the branch
git add new_directory # Stage the new directory (empty directories are not
tracked)
git commit -m "Add new directory" # Commit the directory addition
git push origin branchname # Push the directory creation to remote

# Creating and pushing files inside the directory:


nano new_directory/file1.txt # Create/edit file inside directory
git add new_directory/file1.txt # Stage the new file
git commit -m "Add file1.txt in new_directory" # Commit the new file
git push origin branchname # Push changes to remote

You might also like