« Return to The Lost Chapters

Table of contents
  1. Sharing Code
    1. Push your in-progress code
    2. Find the code on GitHub
    3. Link to specific lines

Sharing Code

Often when working on a project, you’ll want to get another set of eyes on your code. It might be tempting to send over a screenshot or, heaven forbid, take a picture of your screen with your phone 🤮. Don’t do this! It’s much better to push your work to your repo and send a link to your collaborator.

Here’s how to do that:

Push your in-progress code

Start by pushing the current state of your repo to GitHub. If this is the first time pushing to this branch add and commit your files, then run:

$ git push --set-upstream origin solved-html-css

If you’ve already pushed this branch, after adding and committing you can just run:

$ git push

Find the code on GitHub

After you push to your branch, you can find your code by going to your repo on GitHub, navigating to the branch you’re working on, and clicking the file you want to share. For instance, if I wanted to share my code for DoubleHalf, I would push the code: Running the commands to push the code Then go to the branch on GitHub: Selecting and switching to the right branch on github from the dropdown menu And navigate to the DoubleHalf file: The file open in GitHub

Once you’re in the right file, you can point whoever is helping you directly to the right lines by clicking the line you want on the left side of the file in GitHub: Clicking a specific line on the left side of the github file view You can also select multiple lines by shift + clicking a line further down or up the file. This will select the entire range of lines to share. For instance, in the below screenshot I clicked 20, then shift clicked 27 to select every line between 20 and 27: Selecting multiple lines Once you select the lines you want to share, you can copy the URL of the page you’re on and send that wherever you’re sharing your code to. As you can see in the screenshot below, the URL has been updated to reflect the lines that you have selected: URL of the website with #L20-L27 appended to the end If someone clicks that link, they will be directed to exactly the lines that you have selected.

Using this method of code sharing should make the lives of everyone around you easier! And remember, NEVER take a picture of your screen 😡


Back to top

Created by Austin Cory Bart, Josh Lyon, Kurt Hammen, Emma Adelmann, Terry Harvey.