Skip to content

Exercise project for the GitHub for the Rest of Us workshop

Notifications You must be signed in to change notification settings

WPYVR/a-new-castle

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

A New Castle for the King

Once upon a time, in a quaint little village nestled between rolling hills and meandering rivers of Norway, lived three siblings. The eldest was strong and stern, the middle one was swift and sharp, but the youngest, was clever and imaginative. They lived in a humble cottage by the woods, where they spent their days working the lands to feed themselves and their animals.

In this peaceful land, there was a wise and just King who ruled from a grand castle perched high on a hill. His kingdom was prosperous and people lived in harmony. But his castle had started to show the signs of age, and the King dreamt of a majestic new palace; one that would stand through the ages as a testament to the skill and creativity of his subjects.

One bright morning, heralds on horseback spread out from the King's court, trumpeting news of a grand competition. The King sought designs for a new palace, one that would be the marvel of the age. The prize for this monumental task was beyond anyone's wildest dreams: a dinner date with the heir to the Kingdom!

The three siblings decided to pool their unique talents to answer the King’s challenge. They knew this task required meticulous organization, and being children of a humble carpenter, they were well versed in the principles of planning and precision. They agreed to use Git, the mystical tool with the power of version control, to manage their monumental endeavor.

They envisioned a palace of splendor, with towering spires that kissed the skies, majestic gates that welcomed all with a promise of warmth, and enchanting gardens where nature and art danced in a perfect melody. But each sibling had their own vision of beauty and function, and they agreed to work on different parts of the palace.

The eldest would forge the towering spires and strong walls, a symbol of strength and safety. The middle sibling, with their keen eye for detail, decided to craft the gates and the outer defenses, ensuring a welcoming yet secure abode. The youngest, with their boundless imagination, dreamt of lush gardens and serene waterfalls, where people could find joy and peace amidst the beauty of nature.

With the first light of dawn, they set forth on this ambitious journey, their hands itching to create. And with the power of Git, they began the build process...

The Castle Workshop

1. Fork this repository

The journey begins with each participant forking this repository. You can do so using the "fork" button in the top-right corner.
fork
Forking a repository creates a new connected duplicate of the original repository under your own account.

2. Open your repo in GitHub Desktop

Click the green Code button, select the Local tab, and select Open with GitHub Desktop.

3. Open the project in VS Code

In VS Code, navigate to the project folder.

4. Create a branch for the first part of your castle

The castle has three main projects: towers, gates, and gardens. To work on each project in isolation, create a new branch for each of them.

Hot tip: Make one branch, do all the necessary work for the first project in it, then switch back to the main branch, make the next branch for the next project, etc.

  1. Click the "Source Control" icon in the sidebar of the editor
sc
  1. In the sidebar, click the three dots to open the context menu, then select "Branch" and "Create Branch"
branch
  1. Give the branch a descriptive name (ie the name of the part of the castle you're building)
branch-name
  1. In the modal popup, choose "Switch to new branch"
switch
  1. Make sure you're in the new branch by looking at the branch name in the bottom left corner.
current-branch

5. Building the features of the castle

Build the features of the castle in the /Castle folder. Start by creating a new file titled corresponding to the part you're working on (towers.md, gates.md, gardens.md) and then add a description of the part you're building. Here you can be as simple or as creative as you like. See this documentation for information about writing and formatting in Markdown on GitHub.

  • Write text across multiple lines.
  • Add a couple of links.
  • Add an image or other graphic.
  • Be creative (or not).

6. Staging and committing your changes

As you work on your project, use Git to stage and save your changes:

  1. The version contol icon will show you how many files have changes, and in the file browser you'll see an "A" next to any added files.
changes
  1. Click the version control icon to open the version control sidebar panel.
  2. To stage a new file, click the + symbol next to it. The file now moves from the "Changes" section to the "Staged Changes" section.

changes2staged

  1. At this point, Git is actively monitoring the staged files and is ready to committ them to memory.

  2. To commit the changes to memory, first add a committ message in the text field describing what you're adding.

message
  1. Click the blue "Committ & Push" button to commit the change to memory and push it immediately to the GitHub repository.

7. Make additional changes to your file

Add additional changes to your project file, then stage and commit them to get used to the process of saving your work.

8. Switch to the next project branch

When you're finished with one project, stage and commit any final changes, then click the branch indicator in the bottom left corner to open the branch panel. Switch back to the main branch.

branch-selector branch-panel

9. Notice what changed

When you switch to the main branch, the file you've been working on disappears from the Castles folder. This is because it only exists in your project branch. You'll merge everything together later.

10. Finish the other two projects

Go back through steps 4-8 to finish the two other projects, creating one branch and one file for each and staging and committing changes as you go.

11. Create a conflict

In the main branch, go to the /Castle folder and create a file named gardens.md. Add some content to it and stage and commit it to the main branch as normal. This will create a problem later on, and that's what we want.

12. Merge branches

Now it's time to bring all the projects together in the main branch. This is done by merging branches.

Note: Leave the gardens branch for last as it will create a conflict.

  1. In the version control panel, click the three dots and then select Branch and Merge Branch from the dropdowns.
merge
  1. Select the branch you want to merge from the panel.
merge-select
  1. If there are no conflicts, the branches are now merged and you'll see the file from the merged branch in the main branch.

13. Resolve a conflict!

When you try to merge the gardens branch, you'll get a warning that there's a conflict.

conflict

This is because the gardens.md file in the main branch and your gardens branch are different. The conflicting file(s) will open in the editor and you get a visual representation of where the conflict is. In practice, the system adds all conflicting text into the file and you have to decide what you want to keep and what you want to delete.

conflict-viz

Once you've resolve the conflict, add the file from the "Merge changes" section in the version control panel and click Commit again. The commit will now complete as normal.

merge-changes

The End

Once all your project files are in the main branch, the workshop is complete and you now have to argue with your workshop mates about who gets to sit next to the heir to the kingdom at the aforementioned dinner.

About

Exercise project for the GitHub for the Rest of Us workshop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published