Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lukatavcer/0da543d415423e014a08e661df9a5d52 to your computer and use it in GitHub Desktop.
Save lukatavcer/0da543d415423e014a08e661df9a5d52 to your computer and use it in GitHub Desktop.
contributing to github repo without write access: pull from origin repo, push to your own fork

Whenever I want to create pull requests to a repo that I don't have write access to, I:

  1. Fork the original repo to my account.
  2. Clone the original repo to my local machine.
  3. Add my fork as an additional remote and make it the push default.
  4. Make changes in a new branch locally.
  5. Push this branch to my fork.
  6. Create a pull request from there.
git clone https://github.com/<origin_org>/<repo_name>.git
cd <repo_name>
git remote add fork https://github.com/<your_name>/<your_repo>.git
git config remote.pushDefault fork

This way, at a later time point I can easily:

  1. Pull changes from origin into the local master branch.
  2. Create another contribution branch.
  3. Push that to my fork.
  4. Create a new pull request.
cd <repo_name>
git checkout master
git pull
git push # update the fork, which can be relevant for continuous integration checking against the master branch
git checkout -b new-contribution-branch
# make changes and commit
git push

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment