GitHub beginner: How to properly submit changes and apply patches?

I’m completely new to GitHub and struggling with the proper workflow for contributing to projects.

Here’s what happened: I found a project on GitHub that I wanted to contribute to. I cloned the repo to my local machine and started making changes directly without creating any branches (which might have been my first mistake).

After completing my work, I generated a patch file using git diff and emailed it to the project maintainer. However, they responded saying they couldn’t apply the patch and asked me to handle the submission myself.

I’m confused about the correct process. Should I have created a branch before making changes? What’s the standard way to submit contributions to GitHub projects? Also, how do you properly apply a patch file if that’s even the right approach?

Since I still have my patch file, I can easily start over by cloning the repository again and applying my changes manually. But I want to make sure I follow the right workflow this time.

Any guidance on GitHub best practices for beginners would be really helpful.

Email patches are pretty outdated for GitHub workflows. Most maintainers want pull requests through the web interface - it’s got better visibility and discussion tools. When you fork and clone a repo, create a feature branch before making changes. Don’t work directly on main - you’ll get merge conflicts and make collaboration a pain. After pushing your branch to your fork, go to the original repo on GitHub and you’ll see a prompt to create a pull request. The maintainer reviews your code, suggests changes, and merges when ready. Got a patch file already? Apply it to a new branch with git apply patch-file.patch then follow the normal PR workflow. This plays way better with GitHub’s review system.

yeah, def make a branch b4 doing any work – messin with main is risky. fork the repo, create your branch, save your changes, then use that green pull request button on GitHub. much smoother than trying to work with patch files.

Submitting a pull request is indeed the standard procedure for contributing to GitHub projects, not sending patch files. Start by forking the repository to your account and then clone it locally. Create a new branch using git checkout -b feature-name before making any changes; this helps maintain organization. After making your changes, ensure to commit them with clear messages. Use git push origin feature-name to push your branch, then create a pull request from your branch back to the original repository. This method streamlines the process and makes it easier for maintainers to review your contributions.

Yes, directly working on the main branch was a misstep, but you don’t have to start anew. To save your progress, first use git stash to store your uncommitted changes. Next, create a feature branch with git checkout -b my-feature-branch, and retrieve your changes by running git stash pop. Once your modifications are back, ensure to commit your work appropriately. If you haven’t already, fork the original repository and add it as a remote. Push your branch after that. Everyone’s been spot on about the pull request process—this approach will help you retain your earlier efforts. I faced this challenge too when I began; GitHub’s collaboration model can be a bit different if you’re accustomed to dealing with patches.