Here’s a common use case for me: I’m trying to install a github project I’ve never used before. It doesn’t go smoothly and I waste 15 minutes (or 15 hours) only to realize, if the README.md had a single line of required information, this ordeal would have taken me 15 seconds.
Like a good samaritan, I want to add that step to the README, but the time and effort is like an order of magnitude larger than the change: fork the github repo, edit my fork of the README, write a commit message and commit, and create a PR.
Is there a more streamlined way to make these one-off changes to README files?
Note:
- Here’s how I’m going to approach it if there isn’t a better way: I’m going to install the github cli and automate this in a shell script that takes a github clone url as input.
- I want to elaborate on what I mean by "manually" in the title: I don’t mind using an automated script (I’m using WSL.exe with Ubuntu) to streamline this.
2
Answers
The
gh pr create
command will automatically (will prompt you for confirmation) create a fork for you if youre trying to create a PR on a repo you don’t have push access to, so this can be automated with a bash script like:This will, of course, install and setup
gh
beforehandThis is the right way, if you don’t have the GitHub repo’s permission.
You are good samaritan, we know, but there may be some "bad samaritans" who wants to destroy some repos, you can see many of them in, for example torvalds/linux, or some other famous repositories.
So, a check for repo owner / permissioned user, is necessary, to avoid anyone’s annoying attack that wants to destroy the repo. That’s why not anyone allowed to direct edit the repo.
However, fork -> edit -> create PR is sometimes seems complex, so GitHub provides the simpler operation: