This workshop has been retired and is no longer maintained or recommended.
Table of Contents
[text-here]
) when
typing.5. Type: git branch [branch-name]
would be: git branch custom-text
.Note: If you already have a pre-existing workspace you can skip to the next section.
Git requires at least one file in your workspace to be used. The steps below will take you through setting the workspace up.
Login to your Cloud9 homepage - https://c9.io/
Register if you haven’t already.
It should look like this:
Create a workspace!
Press the create a new workspace button.
Give the workspace a good name that conveys what the workspace is used for quickly, and concisely.
-
) for spaces if
you need them.Add a short description, you’ll thank yourself later!
Select public for the privacy settings, it’ll make it easier for people to help you with your project.
If you already have a GitHub project with files and you want to have it ready when you create the workspace you can add its link in the box provided.
For the template you may choose either Custom or HTML5.
Get rid of the unnecessary junk.
On the left sidebar: Right click on README.md
and hello-world.html
.
Select “Delete” and Yes to any warnings.
Close the opened README.md
as well.
Create an index.html
file.
On the left sidebar: Right click and press “New File”.
Name the file index.html
.
Double-click and open it.
Write your name in the index.html
file.
If you don’t know how, you may use this pre-provided code:
<!DOCTYPE html>
<html>
<head></head>
<body>
<p>Your name here</p>
</body>
</html>
Save the index.html
file.
Make sure the active file is the index.html
file by either clicking on it
on the sidebar or clicking anywhere in the code.
You may press Ctrl+S (Windows), Command+S (Mac) or go to File —> Save.
Celebrate!
Your workspace is now ready to be used with Git!
Git is a version control system - https://git-scm.com/
Tracks and manages changes to your code.
Git has tools to show that it has detected a change in the file.
Git allows you to save the same files at different points in time.
Example: If We Used Git With Word Documents
You are using Word and have a file named mystory.docx
.
With Git, it would instead create another version of the file in that point of time.
Git treats every version of code as a “snapshot” that you can look back/ revert to at anytime.
git log
in the terminal displays every change
you’ve saved:(short-form: “repo”)
A repository is a place where your project files are stored.
It’s like a folder inside of your repo.
You use branches for teams collaboration.
Example: Why Branches?
Bob & John are working on one repo and the same files at the same time:
John wants to continue working, but Bob’s bug is not allowing him to continue.
An better alternative: Create two different versions of the same folder and its files of code (different branches).
Example: Branch Merging
main.css
file for the tool bar.main.css
file, but for the header.We don’t want them overlapping each others code!
The main branch
Where coders (you!) merge their final changes.
Diagram of Master Branch Versus Another Branch
GitHub (https://github.com/) is an online Git repository hosting service.
A friendly way to look at and manage repositories and branches with a GUI (graphical user interface).
GitHub Pages is a free service by GitHub that allows you to host a website on their servers (https://pages.github.com/).
index.html
.Nah, not familiar? Follow the steps in Git and GitHub Pages w/ provided link in heading below
Open your terminal
Depending on the workspace configuration you set, it might already be opened.
Hit the ”+” button in the bottom panel area OR on the top-bar click “Window” and “New Terminal”.
Type the command: git add [file]
OR git add .
.
Adds a file to be tracked by git.
git add index.html
.My only file is index.html
.
In the case you have more than one file, the period [.] means add every file in the workspace to the tracked files.
git add .
Type: git commit -m "[commit message here]"
.
Commits changes to be pushed to the branch.
-m
stands for message and in quotations put a message that descriptions
what you did.
git commit -m "first commit"
.Think of committing as packaging something into a package and putting the shipping label on it.
Don’t make bad commit messages: be concise, but clear about what you did.
Type: git push
.
Part two of saving, “pushing”.
Think of pushing as actually shipping the container to the recipient, which in this case is the repo.
After hitting enter, you need to sign with your GitHub credentials.
Type: git branch [branch-name]
.
Creates a branch.
We must name this [branch name] gh-pages
.
gh-pages
.Example command: git branch gh-pages
.
Must be named without spaces — replace a space with a dash (-).
If you create a branch with the wrong name, delete it using:.
git branch -d [name of branch]
.Type: git push gh-pages
.
Push your branch, gh-pages
, online to GitHub.
Afterwards your website should be up at
https://[yourusername].github.io/[reponame]
.
It might take about 30 seconds to fully get online.
Go online to https://[username].github.io/[reponame]
.
Your website is now online! Enter the URL using your credentials and it should show up (wait 30 seconds or more if it doesn’t).
https://nguyenbrian.github.io/example2
.Note: The repo name is different from the branch name.
Example: https://jevinsidhu.github.io/Personal-Website
Celebrate!
Congrats, now you’re a Git (6) God!
Open your terminal.
Depending on the workspace configuration you set, it might already be opened!
Hit the ”+” button in the bottom panel area OR on the top-bar click “Window” (8th from the right) and “New Terminal”.
In the terminal, type: git init
.
This creates a .git file inside of your project folder.
The .git file stores all the location data for your workspace.
This allows you to use git inside your folder.
Type: git remote add [remote-name] [link to repo]
.
Your changes need to connect your local folder to a remote one on GitHub.
On GitHub, click the green button that says “New Repository” near the middle-right area.
Name your repo (e.g hello-world) and give a short description.
Click the green button that says “Create repository”.
Copy the .git link it provides — that’s your link to repo
.
It will be something similar looking to: https://github.com/nguyenbrian/example.git
Example: Remote is a TV Remote Controller.
If you want to change the channel, you hit one channel up on the controller (remote) with your hand (local) and it changes the channel one upon your TV (remote repo).
Open your terminal on Cloud 9 and type the command:
git remote add [remote-name] [link to repo]
[remote-name] is where you name your remote.
Name it something clear.
github
[link to repo] is where you paste the link from earlier.
git remote add github https://github.com/nguyenbrian/example.git
.Type: git add [filename.extension]
OR git add .
.
Adds a file to be tracked by git.
git add index.html
.My only file is index.html
.
In the case you have more than one, the period [.] means add every file in the workspace to the tracked files.
git add .
.Type: git commit -m "[commit message here]"
.
Commits changes to be pushed to the branch.
-m
stands for message and in quotations put a message that descriptions
what you did.
git commit -m "first commit"
.Think of committing as packaging something into a package and putting the shipping label on it.
Don’t make bad commit messages: be concise, but clear about what you did.
Type: git push
.
Part two of saving, “pushing”.
Think of pushing as actually shipping the container to the recipient, which in this case is the repo.
After hitting enter, you need to sign with your GitHub credentials.
Type: git branch [branch-name]
.
Creates a branch.
We must name this [branch name] gh-pages
.
gh-pages
.Example command: git branch gh-pages
.
Must be named without spaces — replace a space with a dash (-).
If you create a branch with the wrong name, delete it using:.
git branch -d [name of branch]
Type: git push gh-pages
.
Push your branch, gh-pages
, online to GitHub.
Afterwards your website should be up at
[yourusername].github.io/[reponame]
.
It might take about 30 seconds to fully get online.
Go online to https://[username].github.io/[reponame]
.
Your website is now online! Enter the URL using your credentials and it should show up (wait 30 seconds or more if it doesn’t).
Note: The repo name is different from the branch name.
Celebrate!
You successfully pushed your site online!
git clone [repo-url]
Cloning a workable copy of a repo onto your local workspace is when you download the repo onto a new computer.
You’ll find the [repo-url]
when you click a into a repo on GitHub and look
for this:
git merge [branch-to-merge-changes-from]
Merging combines the differences from another branch into the current branch you’re working in. For the time being, stay away from this and do a pull request using GitHub.
A pull request means to request changes to be “pulled” from one branch into another. Pull requests are commonly used to merge feature branches into master branches.
A good Git workflow:
Similar to a clone, except instead of merging you would do a pull request to merge your changes to the master repo.
Someone that contributes to the default branch through things such as commits, pull requests and submitting issues.
There are tons of awesome projects people are creating on GitHub with some with thousands and thousands of contributors! Here are just a few:
(your feedback is anonymous + appreciated 💚)