in ,

Learn Git WITH GIt-IT

I used Git-IT for my intro to Git. You will need to dig deeper after this, but it definetly makes the whole Git situation less daunting.

Download Git-It

These are my notes :

Git –version : find version of git on your computer

A repository (repos) is a collection of related items.

Tracking changes is call Version Control

CLI vs GUI : command line interface vs graphic user interface

Basic setup

1 – Create folder: mkdir nameOfFolder
2 – Go to folder: cd nameOfFolder
3 – git init to initialise the folder (ie tell Git to start tracking this folder)
4 – verify everything is set with: git status


If you make changes to this folder by adding a file and type git status, git will tell you that you have a file to add.

1 – git add readme.txt // add the file to git
2 – git commit -m “I created a readme” // save the change to the git repo

If you make another change to your file, you can see the differences with :

3 – git diff // see what’s new in the file

If there is a difference you can go back to 1 and 2:

git add readme.txt
git commit -m “my new commit message”

git add . // Add ALL of the files in the directory


1 – Setup a free github account
2 – Configuring github username

git config –global user.username youUsername // configure your username
git config — global user.username // verify what you put

Connection remotely

Connect your local repo to a remote one and push changes.

1 – Create a new repository on GitHub

Click on + (top right) and follow the steps

Keep the following at none:
.gitignore // list of files that Git should NOT track like files with passwords
licence // type of licence you are giving to other users

2 – Connect your Local to your Remote

In quick setup box, make sure https is selected and copy the URL:

git remote add origin

Your local repo now knows where your remote repo is.

3 – Push work to your Remote

Git has a branching system so that everybody can work on specific parts of the project. The very first branch is called ‘master’. When you push or pull you need to tell git the remove name location AND the name of the branch

git push origin master

The remote name is origin, the branch name is master

4 – Extra commands

git remote add REMOTENAME URL
(git remote add origin

git remote set-url REMOTENAME URL // change the url

(git pull origin master opposite of git push origin master)

git remote -v // view remote address

Forks And Clones

When you fork a repository, you’re creating a copy of it on your Github account (not on your computer.. for now).

On github there is a button fork (top right that looks similar to watch and star.

Click on fork button and choose where you want to fork it.

The url in the browser bar is the address of your fork on GitHubs server:

To bring a fork back onto your computer, you clone it.

On your computer/terminal, make sure you are not in an existing github repository.

pwd // print working directory
cd .. // will take you up a folder level

git clone URLofFORK

git clone
cd patchwork // go to the new fork that you created

git remote -v // see the url of the address of the fork that is set up

Keep the connection even if the original url changes

git remote add upstream

git remote -v // you will see you fork connection as origin and the upstream connection to the original

To sum up:
git remote add REMOTENAME URL
git remote set-url REMOTENAME URL
git remote -v

Git Branches – GitHub Flow

1 – Create a branch

You create branches to keep your workings changes, its an environment where you can try out new ideas without breaking anything. You branch will not be merged until its ready to be reviewed by someone working with you on this project.

Only one rule: anything in the master branch is always deployable.

Best practice is to name you branch something descriptive (easy to understand for the reviewer).

You can also branch off a branch.

Visual representation of branches (GitHub Flow):

2 – Add commits

Commits are a way of showing transparent history of your work so others can understand why you did something. You can go back to a setup of a previous commit if you want to change direction or go back to a functioning version.
Make your commit messages clear

3 – Open a Pull Request

This is when you ask somebody on the team to start discussing your code. You can use the @mention system to buzz somebody

4 – Start talking

This is where you and make sure your going in the right direction, makes changes. This discussion is all saved so you can go back to it to build on your code.

5 – Deploy
You an deploy from a branch before merging to make sure everything is still okay. It’s the final test zone.

6 – Merge
This is where it becomes real. Your branch is merged into the live code. Take off!

Git Branches – Doing it

1 – Create a branch

When you fork a repo, GitHub automatically serves a static website with files called gh-pages.

When you git status patchwork (the forked repo from above), it shows:

Your branch is up to date with ‘origin/gh-pages’

git branch add-username // git branch add-Username this will create a branch

git checkout add-username // go to a branch to work on it

2 – Create a new file

touch fileName.txt // create file
vi fileName.txt // use text editor to add line
mv fileName.txt CONTRIBUTORS // move the file to the CONTRIBUTORS folder
ls | grep ‘cjoe’ // find my file in the full list of contributors

3 – Checking-in changes

git status // will tell you your file needs to be added

git add contributors/filename // add your file to the “get ready to commit” area

git commit -m “commit message” // commit your file with message

git push origin // push your file to your branchname


git checkout -b // use the -b to create and move to the branch in one line

git branch // create a new branch

git checkout // go to the branch

git branch // list all the branches

git branch -m // rename the branch you are working on

git status // which branch am I working on?

Add a collaborator to your project

Collaborator or contributor : somebody working on the same project as you

Go to project > Settings > Manage access > Invite a collaborator

Pull to make sure that you are never out of date
git pull REMOTENAME REMOTEBRANCH // get the latest changes
(git pull origin add-username)

git fetch –dry-run // see changes to the remote before you pull in

Pull requests

So you’ve forked and you’ve made changes in your branch. Now it’s time to send your new code back to the maintainer of the original code so they can put it live.

Visit the original repository that you forked, click on create pull request and follow the motions.


Once your pull request is successfully merged, you don’t need to keep your branch anymore.

Merge locally

git checkout gh-pages //
git merge BRANCHNAME
git branch -d BRANCHNAME

Pull from Upstream

What do you think?

Written by John

Leave a Reply

Your email address will not be published. Required fields are marked *

The Terminal – Code quicker with Command lines

WebScraping Basics with Node.js And Cheerio