learn-git-milestones

PART 2 - Git Collaboration

Forking, branching, pull requests

Also see: PART 1 - Git Basics

8. Create a branch in Github Desktop

  1. Save all your work in VS Code and close your files (this is not required to switch branches, but is a good practice so you don’t lose work!). There should be no changes in your repo.
  2. In Github Desktop, click Fetch and then Pull to make sure you are synced with the remote

branch btn

  1. Click the Branch dropdown (pictured above) to see the other branches in this repo. You should see main (your current branch) and one other. Switch to the other branch.
  2. ✏️ Look in VS Code to see the contents of the other owen-cool-new-feature branch. Summarize the contents of the cool-new-feature file in the completions [8-1] column.

9. Create a branch in Github Desktop

  1. Use Github Desktop to switch back to the main branch.
  2. Click Branch > New Branch… (or use the dropdown)
  3. Name the branch (using no spaces or special characters) using your name + -changes (e.g. owen-changes)
  4. Add a new file (a graphic or text file) with the same name to the repo.
  5. Commit your changes
  6. Publish your new branch and changes to the Github server
  7. Open your repo on https://github.com and find the branches page.
  8. ✏️ Click on your branch and paste the URL into the completions [9-1] column.

10. Create a pull request

A pull request (PR) is the method to move commits from one branch or repo into another branch or repo. This could be used to sync commits across two branches in the same repository or ask another project owner to merge commits from your fork into theirs. Below, you will use a PR to sync changes from your new branch to the main branch.

  1. On your repo Github.com page, click Pull Request.
  2. Click New pull request.
  3. Compare changes between main and your new branch. You should see at least one commit listed, as well as any new or changed files.
  4. Click Create pull request. Then add a message and click Create pull request again.
  5. On the next page, click Merge pull requests to merge the commits into your main branch.
  6. ✏️ On your repo Github.com page, click Insights > Network to see the branch flowchart of your project. Paste the link into the completions [10-1] below.

pr

11. Suggest changes to a partner’s project using a PR

  1. Find a partner and discuss a small improvement to their first-website (or another) project repo (design, code, functionality).
  2. Fork their repository and clone your fork to your computer.
  3. Create a new branch with your name + the name of the improvement.
  4. Make the improvement.
  5. Commit your work to your new branch in your fork.
  6. On on your fork on Github.com click Pull requests > New pull request. This will take you to their repo page where you can see a diff comparing your changes in your fork:repo to their base fork:repo.
  7. ✏️ Create the pull requst as you did above. They will receive an email to accept the change. Copy the link to the pull request to the completions [11-1] table.
  8. Turn in this assignment on Moodle!

Completions (pt.2)

Step Description Completed
8-1 What is in Owen’s dev branch?  
9-1 Link to your new branch on github.com  
10-1 Link to your network graph  
11-1 Link to the PR you made on a partner’s github.com repo