Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to patch code in someone else's project hosted on github

Tags:

git

github

I have cloned someone's open source code hosted on github and made some changes to fix things on various platforms. I'd like to feed this back into the system. How do I contribute this into github so that others get the benefits?

like image 994
Dr.Avalanche Avatar asked Oct 20 '13 09:10

Dr.Avalanche


People also ask

Can I use someone else's GitHub code?

If you want others to use, distribute, modify, or contribute back to your project, you need to include an open source license. For example, someone cannot legally use any part of your GitHub project in their code, even if it's public, unless you explicitly give them the right to do so.

Can I clone someone else's GitHub repository?

You can clone or fork a repository with GitHub Desktop to create a local repository on your computer. You can create a local copy of any repository on GitHub that you have access to by cloning the repository. If you own a repository or have write permissions, you can sync between the local and remote locations.

What happens if someone else takes the Code of your project?

If someone else takes the code but does not violate the license, that’s called forking and is perfectly legitimate, but a polite project will acknowledge the original project, for example “This is a fork of X, aimed to work on mobile devices i How can I check whether the source code of an open-source project contains no malicious content?

Can I share my project with a friend on GitHub?

And don’t share your project to others before you upload it to Github. Your so-called friend could still claim it’s his project, but then you can prove it’s yours. You have the Git history to prove that you’re the person who did it. If he copied your code instead of making his own, he’s likely too stupid to know how to hide what he did.

Do you become the copyright holder of the source code on GitHub?

If you fork a project in GitHub, do you become the copyright holder of the source code? Forking an open-source software project does not change the ownership of copyrights in the source code that was formed from the original project.

How do I apply a patch in Git am?

Using git am to Apply a Patch. The receiver of the patch file (s) can then apply the changes using the git am command: # Switch to the branch where the changes should be applied $ git checkout master # Apply the patch $ git am bugfix.patch # Check what has happened in the commit log $ git log.


1 Answers

I think you want to create a Pull Request.

  1. Push your fixes to a branch of your fork on GitHub
  2. Visit the GitHub page of the original project
  3. Click on Pull Requests, it's somewhere in the top-right
  4. Click on New pull request
  5. Click on compare across forks
  6. Select your own fork + branch
  7. Review the differences. Make sure it's clean.
  8. Create the pull request, and maybe get in touch with the maintainers

UPDATE

If you don't have your fork on GitHub yet, then you have to create that first:

  1. Go to the project's page on GitHub
  2. Click on Fork, it's somewhere in the top-right
  3. Clone your fork to your PC
  4. Make your changes and commit (you can split to multiple smaller commits, it's actually better)
  5. Push your local branch back to GitHub
  6. Now your fork on GitHub has your changes, ready create a Pull Request from it, as explained above.
like image 191
janos Avatar answered Oct 24 '22 18:10

janos