Hi Class! These are instructions for the shell/Terminal comands we went over in class today.
Each line in your terminal will begin with your username and a $ (unless you specified in your shell settings to be something else).
For me, it shows up as yfan$
cd [NAME OF FILE]
Example:
cd Documents/More\ Files/
- If you have spaces in your file names, use a backslash before each space
- To go back one level (one folder):
cd ..
- To go back to your home directory:
cd
(Just that, nothing else)
ls
git --version
git clone [url.git]
So, if I were to clone the jQuery repo, I would go on their Github and copy the git link to their repository (https://github.com/jquery/jquery.git).
And then I would do: git clone https://github.com/jquery/jquery.git
And congrats! You'll have made a local repo on your machine. We refer to the repo that we have on our computer as 'local' and the corresponding repo online (usually on GitHub) as 'remote'.
git status
There are two steps: adding and committing. Think of it like an engagement and then a wedding. Committing is like putting a flag or marker down on the coding road you are riding down. It will allow you to 'return' to the state of your files at that point in time (if you want). Later on, instead of doing undo (ctrl-z) a billion times, it will be easier for you to just turn back the clocks using git and go to a marker where your code was a-okay.
After saving your files...
git add .
The . means all the files. git add-ing is like getting engaged. You haven't fully committed yet but you're pretty darn sure.
git commit -m "[MESSAGE IN HERE]"
The -m
is what we call a "flag". It's telling git that we want to attach a "commit message".
This is committing! You have now put a flag in the ground to let git know that this was a somewhat notable marker in your work so far.
git push origin master
git checkout -b [NAME OF BRANCH]
The -b lets git know that you're creating a new branch. If you would like to create a GitHub page, name your branch gh-pages.
Now that you've created a new branch, you can do your adding and committing in that branch, too. To make sure your remote repo is synced up with your current branch:
git push origin [NAME OF YOUR BRANCH]
So if I have a branch named gh-pages, I would go git push origin gh-pages
.
Here are a bunch of good links and tutorials:
- CodeSchool's Git Tutorial - I haven't used this so I can't tell you much about it except that it's popular. There may be a paywall at some point.
- Udemy's Git Tutorial - This is pretty dry. It reads like an encyclopedia. I would use this as a reference if you're not satisfied with explanations given by these other links. Will require focused reading though. Boo.
- Git Immersion - Going through this was a mandatory part of my Hack Reactor pre-course work. It can be a bit frustrating.
- Git - The Simple Guide - This is like the opposite of Udemy's tutorial. Big letters, quick summaries. However, doesn't dive deep into details.
- Git Documentation - Or else, if all fails, you can read this very dull documentation.