General commands
Force pull
git fetch origin
git reset --hard origin/main
Stash changes
1. Stash your 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)
-
origin→ the name of your remote (default is usuallyorigin). -
main→ replace with your actual branch (could bemaster,develop, etc.). -
This ensures you’re up to date before pushing.
3. Push your branch
-
Sends your local commits to the remote repository.
4. Re-apply your stashed changes (if you want them back)
-
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 applyinstead ofpop.