Skip to content

Instantly share code, notes, and snippets.

@gyorb
Last active May 25, 2018 07:36
Show Gist options
  • Select an option

  • Save gyorb/301ae076b3d8e7bf261e8ba539c14b74 to your computer and use it in GitHub Desktop.

Select an option

Save gyorb/301ae076b3d8e7bf261e8ba539c14b74 to your computer and use it in GitHub Desktop.
git notes

Remove ignored files from your repository's directory

While a regular git clean will ignore them as well, passing the -x switch changes that:

  • Dry run: git clean -xn
  • Clean files: git clean -x
  • Clean by passing the -f (force) or -d (directories): git clean -xdf

Comparing branches/revisions

  • Commits on dev branch but not on master: git log master..dev
  • New commits on dev branch that affect a specific file: git log master..dev -- file/path/lib.py
  • Changes on dev branch but not on master: git diff master..dev
  • Changes on dev branch that affect a specific file: git diff master..dev -- file/path/lib.py

Get the current revision hash for scripting

  • Latest revision on the currently active branch: git rev-parse HEAD

List changed files in a commit

  • list changed files in HEAD: git diff-tree --no-commit-id --name-only -r HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment