Git Cheat Sheet
I’ve experienced the frustration of having to search for commands or refer back to documentation repeatedly. That’s why I’ve created this Git cheat sheet it serves as a personal reminder of those commands that tend to slip from memory. And if it can help me, it can certainly help you too!
fetch the latest changes from the remote repository:
git fetch
reset your project to the latest commit:
git reset --hard origin/master
switch to a specific commit instead of the latest:
git reset --hard <commit-hash>
Change the last commit message:
git commit --amend -m "new commit message"
Git clone a specific branch:
git clone --single-branch --branch <branch-name>
Undo all changes on a file:
git restore <file-name>
Apply the changes from a specific stash to your current working directory:
git stash apply
Rename branch
git branch -m old-branch new-branch