Skip to main content

Section 4.6 Working Solo: The Culminating Experience

As mentioned above, this part is a large activity designed to help you practice the skills and ideas learned in the previous sections. It also represents an example of what a typical workflow might look like. You are welcome and encouraged to refer back to the summary and the sections themselves.
The activity below is broken up into multiple parts. In order to help you remember the procedures, I will not be adding in cross references to the corresponding chapters (but feel free to go back to them if you need to!). That being said, I will add in hints and answers where applicable. Do note that some of the steps have no “correct” answer. This will be noted in the corresponding answer.
The goal of this activity will be to create a new repository and write two poems (or paste your favorite poems, with attributions). Good luck and have fun!

(a)

First, you need to create a new repository. Navigate to GitHub and create this. Name it appropriately for the end goal — you can’t change it later. Make sure you initialize with a README file.
Answer.
Use one of the multiple methods to create a new repo in GitHub. Perhaps name it poems or fav-poems? This part is up to you as long as the name accurately describes the future repo contents. Check the box that says to add a README file.

(b)

Clone your repo on your computer. Navigate to the new repo using your terminal.
Hint.
Make sure you are not “inside” your previous repositories. Nested repositories will not work. So cd to the folder in which you want to place your new repo.
Answer.
Copy the HTTPS link on GitHub. Use git clone <copied-link>. Use cd <repo-name> to move your terminal into that repo.

(c)

You will edit your README file first. Create and switch to a new branch, named appropriately.
Answer.
git branch readme then git switch readme OR git switch -c readme
You may use any branch name you like as long as it’s clear what the branch is for. “readme” seems like it will work nicely.

(d)

Open the README file. Change the default title to a better title. Add a sentence or two explaining what this repo is and why you are creating it. Add any other relevant information you think might help other people looking at your repo would need or like. Save the file.
Answer.
Perhaps a better title would be “My Favorite Poems” or “Two Original Poems”. This can vary. You might explain that this repository contains two of your favorite poems (or two poems you wrote yourself) and this it was born from a project in Better Git Started to help you get more familiar with GitHub and Git functions. This can also vary.

(e)

Check if Git is tracking the README file you just edited.
Answer.
git status

(f)

Stage your file for committing.
Answer.
git add . OR git add README.md, maybe git status to confirm?

(g)

Commit your changes. Add an informative commit message.
Answer.
git commit -m 'edit readme with repo info', maybe git status to confirm?
Of course, your commit message may be different. Perhaps “edit readme” and enough for you.

(h)

Push your changes to GitHub.
Answer.
git push origin <your-branch-name>

(i)

Go to GitHub and open a pull request. Merge your changes into your main branch. You may delete the old branch.
Answer.
“Compare and pull request”, “Merge”, “Confirm merge”. (Check the main branch on GitHub to make sure this worked.)

(j)

Go back to your local computer. Switch back to main and pull in your changes.
Answer.
git switch main then git pull origin main

(k)

You will now create your poems. Create and switch to an appropriately-named branch.
Answer.
git branch poems then git switch poems OR git switch -c poems
You may use any branch name you like as long as it’s clear what the branch is for. “poems” works for me.
Note that you could split up each poem into its own branch. Depending on the length of your poems, you may want to do that in practice but here we will edit both on one branch. That way you can practice two commits in one push!

(l)

Create a new .md file called poem1.md.
Hint.
In VS Code, you can create a new file with the paper-with-a-plus icon in the “Explorer” panel in the top left.
Answer.
Use the hint or use your terminal (touch poem1.md).

(m)

Open the file and use Markdown to write one original poem or paste one of your favorite poems. Make sure to add a title!
If you are pasting someone else’s poem, use proper attribution. This may include, but is not necessarily limited to, name, collection/book from which you found the poem, date published, page numbers, etc.

(n)

Stage your new file. Verify that it is in fact staged.
Answer.
git add . OR git add poem1.md, then git status
Your text editor might also indicate that this worked. For instance, VS Code will show an “A” next to the file name.

(o)

Commit your new file with a good commit message. Verify that it is committed.
Answer.
git commit -m "<commit-message>", git status
Your text editor might also indicate that this worked. For instance, VS Code will remove and letters and colors next to the file name. It will also show your commit message in the “Timeline” panel on the bottom left.

(p)

Do not push yet! You will add your second poem in a second commit before you push. (So this push will have two commits at one time.)
Create a new file titled poem2.md. Open it and add your second original poem or paste your second-favorite poem (with attribution, of course!). Stage this file and commit it with a good commit message.
Answer.
After editing, git add . or git add poem2.md. Then git commit -m "<message>". git status might be useful here.

(q)

Push your new files to GitHub, open a pull request, and merge your changes into main.
Answer.
git push origin <branch-name>, “Compare and pull request”, “Merge”, “Confirm merge”.

(r)

Go back to local and pull in your new changes on main.
Answer.
git switch main, then git pull origin main

(s)

For extra credit, create a new branch and write/paste a third poem. Follow the same processes as above.
If you’d like, use Section B.6 to delete your repository. I won’t be using it again in this book and this might be good practice to see what deleting a repo looks like. On the contrary, it might be nice to keep the repository to show other people that you are active on GitHub and are open to learning how things work. You can always write this fact in a statement on your README.
And that’s that! Hopefully you’re starting to get the hang of this process. If you ever need to practice this again (or need a refresher on what to do), revisit this page. It might take a little bit to become fully comfortable with the process and to remember the order in which to do things. In time, you will get it!