- Collaborate with colleagues using Git
It's very unlikely that you will be the only person working with a Git repository. We have already practised creating branches and merging on our own during the prep, now we will do it with another person.
You will need to find a partner for this exercise. If you have an odd number of people in your cohort you can work in a three, the important thing is that you work on a different repository for parts 1 and 2.
- Create a new directory called
animal-websiteand anindex.htmlfile inside it. - Initialise a Git repository and commit the empty file.
- Create a repository on GitHub and link it to your local repository
- Populate
index.htmlfile with some information about your favourite animal. You should include:- A title
- Two or three sentences about the animal. You can copy something from the internet if you like.
- A picture of the animal
- An unordered list with three facts about the animal, eg. its habitat, its diet, etc
- Remember to commit your changes often!
- When you have built the site push the changes to GitHub and send the repository's url to your partner.
- You will need to add your partner as a collaborator on your repository before they can push to it. Click the
Settingstab on the repository page then go to theCollaborators and teamspage, then clickAdd peopleand enter your partners username. They will get an invite which they need to accept.
- Accept the invitation to collaborate from your partner
- Clone the repository to your computer
- Create a branch called
add-css. Check that you are now working on your new branch. - Create a
styles.cssfile and add it toindex.htmlusing a<link>element. - Add the following styling to the page:
- Change the background colour
- Change the font
- Center the title
- Add a border to the image
- Remember to commit after each change!
- Push your branch to GitHub
- Create a pull request asking to merge your branch to
main
- At this point your partner should have created a pull request. Merge the changes into your
mainbranch. - If you see a message about merge conflicts stop here. That means something has gone wrong somewhere in this process. Post a message in Slack to ask for help.
- You can pull the changes to your laptop to see what's different in the website. Click the three dots next to teh repository name in the source control tab and click "pull".
If you see your partner's changes in your browser then everything has worked, well done! If not then you can post in Slack and ask for help, or speak to a volunteer in class. You should definitely speak to your partner and make sure nobody missed anything while working through the exercise.