DEV Community

Marco
Marco

Posted on • Edited on

Git 🧞‍♂️ cheatsheet

this is a work in progress, I'll keep this list updated... hopefully 😜


Squash

(make the 2+ last commits merge in 1)
the last commits changes will move in the previous one

git rebase -i HEAD~4 you will see only last 4 commits
todo: example 1
change in f any commits you may want to squash like this:
todo: example 2

Move your local one step back

( see changes made on last commit as not staged, this is amazing for review changes made on the last commit)
git reset HEAD~1
If you want to make apply this status use
git reset —hard

Edit last commit message

will open vi and allow you to edit the message
git commit --amend

Reset to a specific commit

  1. see in details list of changes git reflow
  2. move your local to a specific hash git reset [hash]

Somebody else code has been merged an now you have conflict with the code bases

( Apply changes made by somebody else and then add your changes, you may need to solve conflict )
git rebase dev

Force checkout to a specific branch

git reset --hard origin/feat/branch-to-force

Delete branch

git branch -D feat/branch-to-delete

Rename branch

git branch -m feat/new-name-branch

VI essentials commands

Vi start in command mode,

  • for edit mode press I key (exit edit mode with ESC key)
  • for save and exit ESC then :wq
  • for exit without save ESC then :q

Top comments (0)