Common git commands to use

Here are a common git commands that I end up using pretty frequently. Will keep on updating this list

  1. List all remote branches
  2. Simplest is git branch -a Shows all remote and local branches. git branch -r Will show all remote branches only.
    Another way is to use git remote feature like:
    git remote show origin This shows all branches on remote and how they corelate with local repo.
    git ls-remote Will meticulously list all branches and tags.

  3. Just view modified files between 2 branches (without diff)
  4. git diff --name-status master..branch Will list out only filenames git diff master..branch without –name-status will show whole diff.

  5. git remote -v Displays url of remote repo from where local git was pulled
  6. Alternatively use git remote show origin or git config --get remote.origin.url

  7. Viewing Unpushed Git Commits
  8. git log origin/master..HEAD
    To view diffs: git diff origin/master..HEAD
    Another way: git log @{u}..

Leave a Reply

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