Useful Git Commands

Reading Time: < 1 minute

Committed and realized that one of the new files is not yet being tracked?


git log --oneline
git log --stat
git reset HEAD~1

This is assuming you have not pushed to your remote repository.

Git pull not pulling everything

If you always want your server version to reflect a commit from your repo, it’s probably better to use git reset instead of git pull – that way you never invoke merge functionality, but instead set all of the files to exactly what they are in the commit you reset to. For example:


git fetch origin master
git reset --hard FETCH_HEAD

How to replace local branch with remote branch entirely in Git?

  • Make sure you’ve checked out the branch you’re replacing.
  • Assuming that master is the local branch you’re replacing, and that “origin/master” is the remote branch you want to reset to:
git reset --hard origin/master

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *