Terminal & Git Road Bumps

I’ll see how often I’ll be able to post in the morning – I was able to wake up early enough today, but we’ll see how tired I am later on through the course =)

So I ran into a couple of “road bumps” as I was learning some programming skills yesterday and I thought it’d be good to keep a little section where I post the solutions I found – or maybe topics for future research/reading that I can come back to.

Yesterday I was getting acquainted with Terminal, vim, and Git. To a seasoned programmer this is probably baby steps (maybe baby crawl), but I figured I should get as comfortable as possible, as soon as possible, with using the CLI to navigate my file system.

Some CLI (Command Line Interface) commands/shortcuts that I found necessary and useful:

  • touch [file]: Create new file
  • rm -r [dir]: Remove a directory and contents
  • mkdir [dir]: Create new directory

  • Ctrl + L Clears the Screen

  • Ctrl + C Kill whatever you are running
  • Tab Auto-complete files and folder names (Man, I love this!)
  • Ctrl + A Go to the beginning of the line
  • Ctrl + E Go to the end of the line

A full list of commands/shortcuts that I was referencing yesterday is at:
https://github.com/0nn0/terminal-mac-cheatsheet/wiki/Terminal-Cheatsheet-for-Mac-(-basics-)

Screen<em>Shot</em>2015-11-03<em>at</em>8<em>12</em>17_AM
Here I’m messing around with modifying a file with nano and using ‘git diff’ and ‘git status’ to see what has been modified/staged.
 

git-areas

Another issue I ran into while using Git in the terminal was after using the git commit command. Unbeknownst to me, vim was automatically opened as my text editor and I had no idea how to save my commit comments and exit out (I know, what a noob right?)

Well, I found out:

  • To save your work and exit press Esc and then :wq (w for write and q for quit)
  • Or, save and exit by pressing Esc and then :x

Future reading for self:

  • Difference between vim and nano, benefits of one over the other. I’ve heard people approve of one over the other. To me, it just seems like preference.

Duncan Leung

Front End Developer at iHerb.com

Irvine, CA

Subscribe to Duncan Leung: Javascript and Front End Development

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!