Skip to content

Instantly share code, notes, and snippets.

@mike-pete
Last active June 8, 2022 22:26
Show Gist options
  • Save mike-pete/7c2f9a7ca2d6ff67c56cd6f59ac5815b to your computer and use it in GitHub Desktop.
Save mike-pete/7c2f9a7ca2d6ff67c56cd6f59ac5815b to your computer and use it in GitHub Desktop.
Git-Bash Cheatsheet
// install git-bash
https://git-scm.com/downloads
// Sign up with Github
https://github.com/join
// use git bash to generate ssh key
ssh-keygen -t rsa -C "your_email@example.com"
// you need to set a password to avoid issues
// when you are setting your key password, nothing will show in the terminal when you enter your password, this is normal, don't panic!
// print out the pub key
cat ~/.ssh/id_rsa.pub
// copy that key and add it to https://github.com/settings/keys (New SSH key)
// test to make sure everything is peachy:
ssh -T git@github.com
// create a new repo called github-practice (https://github.com/new)
// clone the new repo using git bash
git clone git@github.com:[your user name here]/github-practice.git
// enter the github-practice folder that you just cloned
cd github-practice
// use the touch command to create empty index and style files
touch index.html style.css
// open that folder in VSCode
code ./
// if that didn't work, manually open the folder in VSCode
// to find the current location of your files use the pwd command
pwd
// add code to your new index and style files
// make sure to <link> your css!
// check the current repo status
git status
// track new files
git add -A
// commit those changes
git commit -m "Added index and style files"
// add main branch
git branch -M main
// push the committed changes
git push -u origin main
// track new files
git add -A
// commit those changes
git commit -m "notes here"
// push the committed changes
git push -u origin main
If you get this error:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Do this (if you use ssh for anything talk to Mike before doing this!):
// remove known hosts
rm ~/.ssh/known_hosts
// remove existing keys
rm ~/.ssh/id_rs*
// Repeat step 1
// new file
touch filename
// print working directory
pwd
// move up a directory
cd ../
// move to a new directory
cd directoryName
cd ../parent/otherDirectory
// list the contents of a directory
ls
// delete a file
rm filename
// delete a directory
rm -r directoryName
// make a new directory
mkdir directoryName
// clear the terminal
clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment