Whenever I want to create pull requests to a repo that I don't have write access to, I:
- Fork the original repo to my account.
- Clone the original repo to my local machine.
- Add my fork as an additional remote and make it the push default.
- Make changes in a new branch locally.
- Push this branch to my fork.
- Create a pull request from there.
git clone https://github.com/<origin_org>/<repo_name>.git
cd <repo_name>
git remote add fork [email protected]:<your_name>/<your_repo>.git
git config remote.pushDefault fork
This way, at a later time point I can easily:
- Pull changes from origin into the local master branch.
- Create another contribution branch.
- Push that to my fork.
- 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
- Setting the push default: https://stackoverflow.com/a/30488025
Cheers @brianjbayer, I've updated the gist accordingly.
Although, to be honest, I rarely use this setup nowadays. I usually just use throw-away forks for such contributions, as this is so quick and easy with GitHub:
Once the pull request is resolved, GitHub nowadays offers direct buttons to:
And if I contribute to the same repo again, I just repeat this easier workflow. Also, this avoids cluttering my personal GitHub profile with lots of long-forgotten forks...
So I'd reserve the original gist for projects where I don't have write access, but contribute regularly -- which is very rare.