Skip to content

Using Git

For a guick reference guide for daily Git look at this blog It contains a tutorial for Git beginners. Follow references therein. In particular the Git Cheatsheet link.

Git commands to note

Some commands to help you exploit the full power of git to manage your repository. With reference to this blog

  • git diff : see the difference of local files to remote
  • git log : inspect the log of commits - history of
  • git blame : see who changed what and when in
  • git reflog : show a log of changes to the local repository HEAD. Can show lost work done locally.

  • git reset --hard HEAD - discard staged and unstaged changes since the most recent commits

  • git checkout my_commit : discard unstaged changes since my_commit

    • git checkout HEAD : to discard changes since the most recent commit
    • git cehckout _branch
  • git revert my_commit: undo the effects of changed in my_commit

  • git clean -n : delete untrakced fiels in the local working directory

    • flags to consider: -n -f -d
  • git commit --amend : add your staged changes to the most recetn commit

  • git push my_remote --tags : send all local tags to the remote repository.

  • git branch : list local branches, option -r to list remote branches

  • git checkout : switch to local branch

  • git diff origin/master : difference of local branch to master

  • git branch --merged/no-merded : list branches that have been merged to HEAD

  • git branc -d : will delete a local branch if was already merged to the master!