Skip to main content

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"
  • push → saves your uncommitted changes to the stash stack.

  • -m "message" → lets you label the stash so you know what it is later.

Now your working directory is clean.


2. Pull the latest code (optional but recommended)


git pull origin main
  • origin → the name of your remote (default is usually origin).

  • main → replace with your actual branch (could be master, develop, etc.).

  • This ensures you’re up to date before pushing.


3. Push your branch


git push origin main
  • Sends your local commits to the remote repository.


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


git stash pop
  • This re-applies the last stashed set of changes and removes it from the stash list.

  • If you want to keep the stash around, use git stash apply instead of pop.