Skip to content

Branching and Merging

Erik Chen edited this page Apr 18, 2023 · 1 revision

Branching and Merging

TL,DR: we encourage developing on your own dev branch and merging back to main.

General Approach

  1. Make a branch
  2. Code away on your branch
  3. Commit changes to your branch
  4. Commit your local branch to github
  5. Ask for a Pull Request
  6. Merge!

Branch Mechanics

After you have checked out a repository, you'll want to make a branch, e.g.

git branch your-branch-name
git switch your-branch-name

Git branches are local to your box; at this moment, github has no information about the branch you created.

If you need to switch back to main

git switch main

The filesystem doesn't provide a lot of clues if you're viewing a branch or main. Use this often:

git status

Periodically, you will want to pull files updated in main up to your branch. You can do this with

git pull

However, if you have "uncommitted" edited files in your branch, you won't be able to pull from main. Thus, you need to commit those changes first: "Add" them, then commit.

git add [filename or directory] ...
git commit

Provide details of what is changing. Note that this doesn't actually write anything back to github, but it will allow you to pull from main. Beware of potential conflicts when you pull from main, and resolve them in your branch.

Commit your branch to github

Before you pull your changes to main, you need to make github aware of your branch.

git push -u origin your-branch-name

This now allows the Github, and most importantly, the Github pull request UI, to be able to manage your pull request.

Using SSH, not https

If you originally checked out code via https, you'll need to re-home your repository to use SSH. See instructions on setting up SSH if you haven't yet set up SSH keys.

git remote set-url origin git@github.com:OurPlanscape/Planscape.git

Using the github pull tool

Go here and click the big green button in the upper-right to create a pull request.

Note that this will bring up a reference to PatManley/Planscape. Change the option to OurPlanscape/Planscape: 5f8sUpF4WFxZhCJ

Doing this minorly changes the selection dropdowns. On the right-side dropdown, change that to the name of your branch: 7FmZ6R62ynpTEfD

Then, hit the big green button on the upper-right again, and you have a pull request! Don't forget to give you pull request a good oneline name and a description.

You'll want to assign the pull request to a team member for review before you can pull it up into main.

Historical Footnote

The codebase in github will note that OurPlanscape/Planscape came from PatManley/Planscape. We don't need to merge anything back to PatManley/Planscape.