Editing Files as a Collaborator in GitHub
— coding, GitHub, software development — 1 min read
![github web collaborator](/static/0cfa88e87981ff4a5b1dc96d744b344e/7d769/github-web-collaborator.png)
I recently ran into a problem where GitHub wouldn't let me edit and pull request markdown files in the web in a repository I am a collaborator on. Instead, it just gave me the message "You must be on a branch to make or propose changes to this file."
I love that GitHub has the capability for me to edit and pull request code (particularly text-based files, like Markdown) in the web. It's really convenient, especially when you're just looking to fix a typo or add a quick sentence. That way you don't have to clone the whole repository to your computer, which can be a real pain, especially if you're literally just fixing a typo.
So I was a little frustrated the other day when I got this message when I tried to edit a file:
![You must be on a branch to make or propose changes to this file GitHub You Must be on a Branch](/static/9d635b574140dc8ca414b20450feac0d/b3911/github-youmustbeonabranch.png)
Weird, right? I'd never seen this before, so I was pretty confused. Luckily, though, there's a very easy fix, as I learned from this Stack Overflow thread.
Turns out, because I'd searched for the file in the repository instead of navigating directly to it (it's a big repository, so I was trying to save myself some scrolling time), GitHub gave me that file in a specific commit rather than in the main branch:
![GitHub Commit GitHub Commit](/static/d6baa31f4dadf2adc2ce7fd9817e1809/0455b/github-inacommit.png)
Simply switch that to the master branch...
![GitHub Switch to Master GitHub Switch to Master](/static/439bbc4eff946ace6b1f529727e9955e/f7709/github-switchtomaster.png)
And you're all set!
![GitHub lets you edit GitHub Lets you edit](/static/acc66b37e5748d4265e53e79ab09a8f3/b31ad/github-youcanedit.png)
Thanks for reading! I hope you find this and other articles here at ilyanaDev helpful! Be sure to follow me on Twitter @ilyanaDev.