Skip to content

Instantly share code, notes, and snippets.

@lhoupert
Last active January 21, 2021 15:10
Show Gist options
  • Save lhoupert/01daa22e0b2a4171c20a291df14e661b to your computer and use it in GitHub Desktop.
Save lhoupert/01daa22e0b2a4171c20a291df14e661b to your computer and use it in GitHub Desktop.
Notes on Git workflow for contributing to open source repositories

Notes from Aaron Meurer's tutorial on the git workflow

Cloning and forking the repository

  1. Clone the repository.
git clone clone-url
  1. Fork the repo on GitHub to your personal account. Click the Fork button on the main repo page.

  2. Add your fork as a remote. This remote will be named after your github username. Go to the fork of the user repository (e.g. https://github.com/username/xxxx - replace username with the GitHub username-), and copy the clone url as in step 1. cd to the clone from step 1 and run

git remote add your-github-username fork-url

Making Changes

Before any changes, a branch should be created. Remember to never commit to master. The current terminal should be set up to display the current active branch.

  1. Update master. Before you make any changes, first checkout master and pull in the latest changes
git checkout master
git pull
  1. Create a branch. Once this is done, create a new branch. Make a branch name that is short, descriptive, and unique. Some examples of good branch names are fix-install, docs-cleanup, and add-travis-ci. Some examples of bad branch names are feature, fix, and patch. To create the branch:
git checkout -b branch-name
  1. Make your changes and commit them. Keep commits atomic <-> each commit should represent a single unit of change. Also write helpful commit messages, so that someone can understand what the commit does just from reading the message without having to read the diff.
git add filename [filename ...]
git commit -m "..."
  1. Push up your changes. Push the changes to your fork.
git push your-github-username branch-name
  1. Make a pull request. Go to the user fork repo on GitHub to see a button to create a pull request from the user branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment