Getting started with Git and GitHub
Date: Wed 30 Jan 2019
Goals
Our goals this week include:
Setting up Git on our local machine
Creating a remote repository on
GitHub
Initializing a local repository on your local machine
Creating website architecture, i.e., base files and directories for
your website, on our local repository
Staging, committing, and pushing those files to our remote repository
Basic definitions:
Setting up Git on our local machine
First, you should configure Git on your local machine (this part has
nothing to do with GitHub). Following the instructions at the link
below, assuming you have already downloaded Git onto your machine. This
will configure Git to track your name and email address, which is an
important part of version control.
Configure user name:
https://help.github.com/articles/setting-your-username-in-git/
Configure email address:
https://help.github.com/articles/setting-your-commit-email-address-in-git/
I won't provide the instructions here in this transcript because it will
vary a little bit based on your operating system. Do follow the
instructions for configuring Git for every repository and not just a
single repository.
Create a remote repository
Sign-in to your GitHub account
Click on the Plus/Drop-down icon at the top of the screen and select,
New repository.
Add a name for your repository. Do not click on the Initialize this
repository with a README file.
You will need the URL for your remote repository. GitHub offers two
protocols for connecting to remote: HTTPS and SSH. Select the HTTPS
protocol.
Initialize a local repository on your local machine
On your local machine, pick a suitable location for your web
development project, create a folder (can be the same name as the
repository you created on GitHub).
Now, navigate to that folder on your machine using the command line
for your operating system. If you're using a Windows machine, you may
want to consult GitHub documentation (YouTube videos, etc.) for how
to accomplish this, or you may want to seek help from your
classmates.
Then, follow the instructions on the GitHub screen under the section
titled ...or create a new repository on the command line. This
must be done within the base folder that you created.
Congratulations, you have now initialized your first repository, staged
your first files, and pushed them to the remote repository (i.e., your
GitHub repo).
Create website architecture
In that folder, create the following files and sub-folders (aka,
directories):
a file named: index.html
a file named: .gitignore
a folder named: images
a folder named: styles
a folder named: scripts
Stage, commit, and push to remote repository
We have now made changes to our local repository that we need to
stage, commit, and push to our remote repository. To do that, we'll
repeat, but modify, the commands we used to create the repository on
the command line:
git status
git add *
git commit -m "set up website architecture"
git push origin master
Congratulations again! Now we are gitting. We don't have to stage,
commit, and push all file modifications. We can repeat this process
after each session or after reaching certain goals, but it's okay to do
it often because by pushing changes to remote, we also backup those
changes, which would allow us to pull them in case of loss. We also, by
doing this process, create the ability to revert to different versions
of our project in case we have made a mistake.