Using SSH console to speed up coding

in Development


Find code

Use grep to quickly scan your whole project for a given string.

grep -inFR "needle" /path/to/haystack
  • i: case insensitive search
  • n: output matched line numbers
  • F: do not treat search string as regular expression
  • R: recursive search

Stage code for committing

  • Use git add -i to review the code you're about to stage. Choose a to add new files, u to update the tracked files in full, or p to stage code piece by piece. You will then be able to add the full chunk or enter s to split it. If you need to edit a given chunk, entering e will bring up the native OS editor (vi in my case)
  • Use git diff --staged to review the staged code before committing. This helps catching unwanted edits, e.g. hardcoded passwords or unnecessary code comments
#tips #best-practices #grep