Git

Activating an SSH Key

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/server

Order Of Operations

Local > remote

  1. Add the changed files
  2. commit the files
  3. push to repo
git add FILE_NAME
git commit -m "message"
git push origin main

Remote -> local

  1. Pull changes to local folder
git pull origin main

 

 

 

 

General commands

Force pull

git fetch origin
git reset --hard origin/main

Stash changes

1. Stash your changes


git stash push -m "My local changes"

Now your working directory is clean.


2. Pull the latest code (optional but recommended)


git pull origin main

3. Push your branch


git push origin main

4. Re-apply your stashed changes (if you want them back)


git stash pop