Beginner's Guide to Terminal, plus Bash vs Git (Week 1)

terminal
bash
git
#1

Hi all,

I just wrapped up my first week in Intro 1, and Kevin suggested that I share my notes based on some of the questions that I asked. As a beginner to coding, I’m hoping my layman’s notes may help a fellow beginner in the future.

Q: What is Terminal?
A: Terminal is the default macOS command-line interface.

Q: I’m on a Mac. How do I open my Terminal?
A: Go to your Applications folder. Then go to your Utilities folder. The application Terminal is in there. You can also use Spotlight (Command + Space then type Terminal).

Q: What commands were we using in the Terminal this week?
A: We learned some basic Bash and Git commands.

Q: What is Bash? For that matter, what is Git?
A: We use Bash to navigate directories, create or delete files, list folder contents, etc. Examples of Bash commands are: cd, mkdir, touch, and rm.

Q: What Bash commands did we cover the first week?
A:

  • cd —> go home
  • cd ~/Desktop/ —> go to desktop
  • mkdir <folder name> —> make directory aka folder
  • touch <file name> —> create file
  • ls —> list files in a certain directory
  • . —> here (your current working directory)
  • .. -> “up a level” (the previous directory)

We also had a brief run-in with a weird text editor called vim. If you ever find yourself inside of vim, you can exit by pressing escape and typing

  • :q!

Q: Is there a good resource for more Bash commands?
A: https://www.learnenough.com/command-line-tutorial

Q: What is Git?
A: git is a version control tool that allows you to efficiently track changes that one or more developers might contribute to a the given codebase.
Using git, we can push our code to a remote repository hosted on GitHub (aka the “cloud” that we send our local Git files to). During our first week, we focused on the following Git commands:

  • git status —> checks in to see how everything is
  • git add _file name_ --> add your local files to Git’s “staging area”. In layman’s terms, this “staging area” is where you collect all the work you want to commit before pushing it to GitHub
  • git commit -m “_your message_” --> “Commits” your local files. Think of this as like a “bookmark”, along with a personal note describing what changes you made.
  • git push origin gh-pages --> “Pushes” your local files. Layman’s terms: you’re sending your local files - in your local copy of the repository - to a remote copy of the repository on GitHub.

Let’s review the order of arguments that git push accepts:
git push <remote repository> <local branch>

So when we issue git push origin gh-pages, we’re saying:

“Okay Git, push my local gh-pages branch to the remote repository - which we’re calling origin since that’s easier than trying to remember the whole URL of the remote repo”

Q: Is there a good resource for Git commands?
A: http://files.zeroturnaround.com/pdf/zt_git_cheat_sheet.pdf

Also, you can find answers to almost every Git question imaginable on Stack Overflow.

3 Likes
#2

hey @johnjung77, thanks for documenting your findings and sharing with the rest of us! Not only is it a generous thing to do, but it’ll help you grasp and retain the information much more quickly :+1:

1 Like