25 min
Let's simulate using Git in a team environment to help us better prepare for development in a professional setting.
Split up into teams of 3-4. If You're in a group of 3, then the Release Manager will also play the role of Developer 3.
- Release Manager - Responsible for managing the remote repository, merging branches
- Developer 1
- Developer 2
- Developer 3
The person who should be following a series of steps will be marked like DEVELOPER 1
- Create a public repository in your GitHub account
- Add the 2-3 additional developers in your team as Collaborators
- Clone the newly created repository to your computer (you can use any location for this exercise, your Desktop for example)
- In the terminal, navigate to the working directory you just cloned
- Create a new branch called
foundation
and switch to it - Create a file named
index.html
- Add the base HTML structure into the page, don't worry about including anything else
- Stage the file for your next commit
- Commit the file
- Stop and Think: Do the other developers have access to the file you created yet?
- Push the branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 1
- If they look good, approve the changes by merging the new
foundation
branch intomaster
- Pull down the latest changes from the remote repository
- Create a new branch named
quotes
and switch to it - The page is in need of some content. Add an
<h1>
element with a title for the page - Additionally, add a
<blockquote>
element to the page with your favorite quote, be sure to include the author - Go ahead and create a file named
style.css
, but don't worry about adding anything to it yet - Stage your changes for the next commit
- Commit your changes
- Push the branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 2
- If they look good, approve the changes by merging the new
quotes
branch intomaster
- Pull down the latest changes from the remote repository
- Create a new branch named
styles
and switch to it - Add a couple of very basic styles in
index.html
(e.g. add a background color, style the quote) - Stage your changes for the next commit
- Commit your changes
- You think that the author attributed to the quote is incorrect. You believe it's supposed to be Justin Bieber. Change the author to reflect this
- Stage your changes for the next commit
- Commit your changes
- Push the branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 3
- You don't notice the error with the author, so just approve the changes by merging the new
styles
branch intomaster
- Your biggest client notices that the author of the quote is completely incorrect. Developer 3 is on vacation, and you're tasked to fix this
- Pull down the latest changes from the remote repository
- Create a new branch named
hotfix1
and switch to it - Correct the author
- Stage your changes for the next commit
- Commit your changes
- DO NOT push your changes to the remote repository yet
- Pull down the latest changes from the remote repository
- Create a new branch named
authorupdate
and switch to it - Your manager asked you to make the author's name all uppercase, so go ahead and do that.
- Stage your changes for the next commit
- DO NOT commit your changes or push them to the remote repository yet
- Push the
hotfix1
branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 1
- Approve the changes by merging the new
hotfix1
branch intomaster
- Switch to the
master
branch - Pull down the latest changes from the remote repository
- You noticed some files have changed, and you want the new branch you're working on to also have these changes
- Switch to the existing
authorupdate
branch that you're still working on - Run
git merge master
to get those updates - You should have a conflict now with the new changes clashing with yours. Resolve these conflicts
- Stage your changes for the next commit
- Commit your changes
- Push the branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 2
- Approve the changes by merging the new
authorupdate
branch intomaster
- Pull down the latest changes from the remote repository
- Create a new branch named
hotfix2
and switch to it - You're absolutely certain the author's name is supposed to be Justin Bieber. Change it back to that again
- Stage your changes for the next commit
- Commit your changes
- Push the branch to the remote repository and create a pull request
- Go to GitHub and view the repository you created for your team
- On the right hand side click on "Pull requests"
- Review the changes being proposed by Developer 3
- This time, you learned your lesson and instead of merging you leave a comment about how this is incorrect and just close the request without merging.
- Ask Developer 3 to stop doing this and tell them there's more to life than Justin Bieber