GitHub is one of the most popular and important development tools you will use. It keeps a history of your development activity and can be used as a tool to show potential employers your code and coding habits.
GitHub can also be used to help multiple developers work on the same code set without overwriting each other's additions. However, this task will focus on using the tool as an individual. In this task you will use GitHub to:
- Store and share your code
- Create backups and version control
- Practice using the Git and GitHub CLI
Remember that Git and GitHub are two different things. Just like Gmail is one of many providers of email. GitHub is one of many providers for storing Git repositories.
Git and GitHub can be hard at first. And if you have never used the Command Line, it can be a bit intimidating. However, it might be the most important and widely used development tool.
In this class we will use Git through the command line. Start by following the Getting Started - Git Installation. Once you're done run the following command in your Terminal (Mac/Linux) or Git Bash (Windows) to confirm it has been installed:
git --version
We will also use the GitHub Command Line Interface (CLI) Tool. Please download and install the proper version. Once you're done, run the following command in your Terminal (Mac/Linux) or Git Bash (Windows) to confirm it has been installed:
gh --version
Once you have the GitHub CLI installed, use it to login to your GitHub account:
-
Run the following command:
gh auth login
-
Select
GitHub.com
. -
Select
HTTPS
. -
Answer
Y
to authenticate Git with your GitHub credentials. -
Select
Login with a web browser
. -
Press
ENTER
. -
Enter the eight digit code from the Terminal into the browser and then click
Authorize github
. -
Confirm you are logged in by checking the local configuration settings:
git config -l
When using Git and GitHub as an individual, you will usually follow these steps:
-
Create a new repo for your project.
-
Clone the repo to you computer:
git clone https://github.com/BrickMMO/tasks.git
You can find the URL of a GitHub repo here:
-
Make changes using your code editor.
-
Add current changes to the main copy:
git add .
-
Commit changes to the main copy:
git commit -am "Describe latest changes"
-
Push the changes to your GitHub repo:
git push origin main
When you are working as an individual, you will not need to create any additional branches. You can simply add and commit all your changes directly to the main
branch like in the examples above.
You can get detailed instructions of this process on my github-demo-branching repo.
Use Git and GitHub as much as possible! It will force you to practice the skill, you will have a backup of all your work, and your GitHub contributions chart will start turning green!
I would recommend the following:
- Create a GitHub repo for each class. Put all your class files in that repo. Push the files from class to your GitHub account at the end of each class (or even more often).
- Create a GitHub repo for each assignment. You can use these repos to hand assignments in. And you can also use a GitHub repo to host a project (we cover that later in the Deployment Task).
- If you're learning a new skill, create a repo and store the code there in case you need it for later.
Be consistent! As a developer you should be obsessed with C\consistency!
-
Use consistent naming conventions.
-
Give your files nice clean names like
logo-github.png
. NotIMG-20170407-WA0007_resized.jpg
,IMG-20170407-WA0007.jpg
, orCopy of IMG-20170407-WA0007.jpg
. -
Organize your files into classes, and weeks, and topics:
http5111 │ README.md │ └── week1 │ │ headings.html │ │ paragraphs.html │ └── week2 │ images.html │ tables.html └── images │ logo.jpg
I have written a set of rules for myself (and all BrickMMO development) to follow when working with GitHub repos and README.md files. These rules are called _readme. You can use these as a starting point.
To complete this task, follow these steps:
- Create a repo for each of your classes.
- Clone each of those repos to your compauter.
- Put your class files into those repos.
- Add, commit, and push those files to your GitHub account.
Submit your class GitHub repo URLs to the Individuals assignment in Blackboard.