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 journey begins with each participant forking this repository. You can do so using the "fork" button in the top-right corner.
Forking a repository creates a new connected duplicate of the original repository under your own account.
Click the green Code
button, select the Local
tab, and select Open with GitHub Desktop
.
In VS Code, navigate to the project folder.
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.
- Click the "Source Control" icon in the sidebar of the editor
- In the sidebar, click the three dots to open the context menu, then select "Branch" and "Create Branch"
- Give the branch a descriptive name (ie the name of the part of the castle you're building)
- In the modal popup, choose "Switch to new branch"
- Make sure you're in the new branch by looking at the branch name in the bottom left corner.
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).
As you work on your project, use Git to stage and save your changes:
- 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.
- Click the version control icon to open the version control sidebar panel.
- To stage a new file, click the + symbol next to it. The file now moves from the "Changes" section to the "Staged Changes" section.
-
At this point, Git is actively monitoring the staged files and is ready to committ them to memory.
-
To commit the changes to memory, first add a committ message in the text field describing what you're adding.
- Click the blue "Committ & Push" button to commit the change to memory and push it immediately to the GitHub repository.
Add additional changes to your project file, then stage and commit them to get used to the process of saving your work.
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.
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.
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.
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.
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.
- In the version control panel, click the three dots and then select
Branch
andMerge Branch
from the dropdowns.
- Select the branch you want to merge from the panel.
- If there are no conflicts, the branches are now merged and you'll see the file from the merged branch in the
main
branch.
When you try to merge the gardens
branch, you'll get a warning that there's a 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.
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.
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.