Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Last active January 10, 2019 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/3d979e0c406c055ad83b8986298cc340 to your computer and use it in GitHub Desktop.
Save cameronjonesweb/3d979e0c406c055ad83b8986298cc340 to your computer and use it in GitHub Desktop.
Useful bash commands
# Change file permissions on a sever
## Change owner
$ chown -R owner filename
## Change group
$ chgrp -R group filename
## Change mode
$ chmod 755 filename
# Git
## Add all of file extension
$ git add ./\*.ext
## Add only modified files
$ git add -u
## Diff for a single file
$ git log -p -1 filename.ext
## Diff between any 2 commits
$ git diff *hash1* *hash2* --name-only
## Diff between latest commit and a specified commit
$ git diff master *hash* --name-only
## Rename current branch
$ git branch -m 'my-new-branch-name'
## Run git in silent mode (no output)
$ git *command* -q
# Grep
## Search for a phrase recursively in the current directory
$ grep -iRn 'searchterm' .
## Search specific file extensions
$ grep -iRn 'searchterm' . --include=*.ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment