github

Pushing to someone else's branch on Github


I'm fairly new to GitHub, so I hope you can help out. There's a branch on a repo that I want to push changes to, but I'm not added as a collaborator on it. What steps do I need to take to push changes to that branch?

I have done some research and found that I may need to fork the repo, make changes locally then create a pull request, but I'm still a bit confused about it. I would appreciate any help.


Solution

  • You can't simply push to a branch for which you don't have write access. Instead, you can fork the repo by clicking the fork button.

    Then, clone the repo locally by using the command below:

    git clone https://github.com/your-username/project.git
    

    Next, you need to checkout to the branch in which you need to make the changes:

    git checkout branch_name
    

    After making the necessary changes, commit and push them:

    git add --all .
    git commit -m "changes description"
    git push
    

    Now visit the repository in your profile. You can see a notification to open a new pull request.

    Please see this for more info: https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/