The purpose of this practical is to simulate how a collaborative git work flow would operate in the 'real word'.
Using your local knowledge you are going to create a visit Rotterdam Website.
We're going to use git to collaborate on this project. Firstly install git on your local computer:
instructions can be found here
Once installed if you are on a mac open up terminal, on windows open up git bash.
git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.com
You can check your config with
You can check your configuration with:
git config --list
If you don't have one already set up a GitHub account at github.com.
- Use a real name, remember it's part of your professional profile
-
Nominate a team leader you can form one group or use smaller sub groups. Ideally the team leader would have used git and gitHub before
-
The downloaded zip file needs to be unzipped
-
Next, the team leader should navigate to the decompressed folder
-
Navigate on command line to where you want to work: (using terminal or gitBash)
``` cd <directory name> //to change directory cd .. //to move up one directory ```
or
-
You can type
cd
then drag the folder into the terminal/gitBash window.
-
-
Next, the team leader must create a new repository:
git init
git add -A
git commit -m "initial commit"
-
The team leader should then create a new repository on
gitHub
. GitHub hub will provide instructions on how to add an existing project. -
The team leader should grant access to the repository to everyone else in the team. This can be done from the repository settings
-
Everyone in the team should then clone the repository to their local computer.
get the repository address by pressing the clone button
- Type
git clone <projectadress>
and press enter - A new folder called
rotterdamtravelguide
should be created containing the starter project. - Type
cd rotterdamtravelguide
and press enter in order to navigate into that project folder.
#The Task
-
As a team pick out one attraction each to write about. This can be anything that takes their fancy.
-
Each team member should then create a new branch, so they can work on their attraction in isolation. To create a new branch type:
git checkout -b "branch_name"
Note, branch names can not contain spaces.
-
This will create a new branch and switch to it. If you type
git branch
you should see you are on your relevant branch -
Updated the html pages relating to your chosen attraction.
- Commit regularly
git add -A git commit -m "this is a commit message"
- If you make a mistake:
git reset --hard
resets the head to the last commit
#Pull requests
- When each team member feels they have finished their section they should push their features branch to the github origin origin
git push -u origin <the name of your branch>
-
The team member should then locate their branch on gitHub and raise a pull request.
-
If the team leader is happy with the pull request, he should merge it into the project.
-
The team member should switch back to the master branch and pull the latest changes:
git checkout master
git pull origin master
If we have time, let's make a live website
-
Not only is GitHub great for collaborating, they'll also host your website for free!
-
Check out a new branch it must be called
gh-pages
-
Push your new branch to the origin
git push -u origin gh-pages
-
That's it, your website should now be visible at:
-
https://<username>.github.io/<repository name
> -
Mine is
https://joeappleton18.github.io/rotterdamtravelguide
-