问题
I am trying to make changes to a GitHub repository for which I have been invited as a collaborator. I can create new files and modify them, but when I tried to do any changes to an existent file I saw this message saying "You must be on a branch to make or propose changes to this file".
Then only after I push a commit through the terminal, I was able to modify this file on the GitHub pages. Is this an expected behavior?
Thanks for your time, Cheers
回答1:
It sounds like the repository you're using has protected their main branch (usually master
). This is usually because they want changes to be done with a pull request-based workflow to ensure code review and CI cleanliness before merging.
When you create a branch on the command line and push it, you should be able to modify it as normal, since it's not a protected branch. Similarly, if you create a branch through the UI, you should also be able to edit it. However, you won't be able to push directly to the main branch or edit it directly in the UI.
回答2:
I got it:
I came to the source file using the search, hence the result I got was on a specific commit:
https://github.com/organisation/repo/blob/252e66a59e1b717df6b4467e4de025fcfd254a88/pages/file.ext
Changing the tree to the master branch: restores the ability to edit the file.
来源:https://stackoverflow.com/questions/55299930/editing-files-as-a-collaborator-on-github