Skip to content

Instantly share code, notes, and snippets.

@MarcoDeJong
Last active June 13, 2018 08:08
Show Gist options
  • Save MarcoDeJong/b1e8461202565265b95d7e653768528a to your computer and use it in GitHub Desktop.
Save MarcoDeJong/b1e8461202565265b95d7e653768528a to your computer and use it in GitHub Desktop.
Less obvious git commands

Less obvious git commands

To prevent myself from Googling over and over, I will gather some of the hard to remember git commands

Clone just the tip of a specified branch (no history)

git clone --depth=1 --branch=master git://someserver/somerepo

Search commit messages

git log --oneline | grep PATTERN

Show commit messages by current user

git log --since=5.days --author="$(git config user.name)"

Search removed file

git log --full-history -- FILENAME

Add gh-pages branch

  • Add build folder to .gitignore in master/development branch
  • git checkout --orphan gh-pages
  • git rm -rf .
  • Make a first commit and push
  • Script something like git checkout gh-pages && git add --all && git commit -m "Release at $(date)" && git push origin gh-pages or use Travis to deploy

Remove local branches which are removed from remote

  • git remote prune origin --dry-run
  • git remote prune origin

Push everything to remote

  • git push REMOTE --all
  • git push REMOTE --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment