Kitaab

git tips and tricks

dev git

published 2021-07-07 05:44

updated 2023-07-05 21:18

= Squash Commits! =

  • git reset --soft HEAD~N where N is the number of commits you want to squash
  • Your changes have been reverted, now you can add them all into a single commit
  • If you already pushed part of this branch remotely, you force push is your friend :3

Drop commits out of current branch

  • git rebase -i master (interactively rebase from master)
  • drop the commits you dont want
  • git push origin <branch> -f

Cherry Picking

Git Cherry Pick

Diffing between local and remote repositories

  • git fetch <remote_repo> <remote_branach>
  • git diff --summary FETCH_HEAD

Or for a specific file:

  • git diff FETCH_HEAD -- <file>