Submodule 1.2: Version control. Git - Github

Online Git Repositories

On Github

Sign up for an account at GitHub. Don't loose Your credentials!!

Then set up an online Git repository named yourNameWEB2GitTest. Note the URL of your online Git repository.

URL of Github Pepo

On Computer, push to Github

Open your Terminal and go to your topic git folder.

At the prompt, type the following to set up your local repository to link to your online Git repository:

git remote add origin <repository URL>

The command git remote adds a new remote in the directory your repository is stored at. It takes two arguments, a remote name, for example, origin and a remote URL. 

At the prompt, type the following to push the commits to the online repository:

git push -u origin master

It's possible to have an error. Github doesn't know who is trying to upload content. 

User error! Type your credentials of Github

Inform with your Github credentials to complete the upload.

Done!

Explore your repository on Github, the commits, the insights etc. You can see a rich environment with a lot of graphical representations!

On Computer, new changes

In the jumbotron div of the index.html file add the following code after the <h1> tag:

<h3>We will see some of the world's chocolates!</h3>

Check your git status and let's commit using the command

git commit -a -m "third commit"

The -a argument stands for all changes and the staging phase (git add and git commit). Check the changes in the history of the index.html file.

Let's update the remote Github for the changes using the command

git push <remote-name> <branch-name>. These are possibly origin and master, so a possible commant is git push origin master

To find the names write git remote and git branch

On Github, new changes

Update the index.html on Github with the 

<p>It arrived to Europe in 16<sup>th</sup> century</p>

and add the commit message Fourh commit. Adding paragraph in index.html on Github

On the computer, fetching from Github

Let's update our local repository:

We can grab all the new information by using

git fetch <remote-name> possibly git fetch origin

in the terminal.

Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches.

We have to use 

git pull

to update your local branch!

OK!!