Dr.Avalanche
Dr.Avalanche

Reputation: 1996

How to patch code in someone else's project hosted on 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?

Upvotes: 19

Views: 4337

Answers (3)

sudo bangbang
sudo bangbang

Reputation: 28189

In github, you can send a pull request to patch code in someone else's project. I've started a project to help people making their first GitHub pull request. You can do the hands-on tutorial to make your first PR here

The workflow is simple as

  • Fork the repo in github..
  • Clone the repo to your local machine.
  • Make a branch for changes and make necessary changes
  • Push your changes to your fork on GitHub git push origin branch-name
  • Go to your fork on GitHub to see a Compare and pull request button
  • Click on it and give necessary details

Upvotes: 0

janos
janos

Reputation: 124646

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.

Upvotes: 28

Gaurav Bhor
Gaurav Bhor

Reputation: 1157

If you are contributor:

  1. Create your own branch using git branch [branch_name]
  2. Make your changes in the code of that branch
  3. If you have added new files you will need the git add .(adds all the new files) command to notify GIT of your new files. After this GIT will start tracking the new file.
  4. Commit the changes git commit -am "Commit message"
  5. Push your changes using git push origin [branch_name]

PS: You are not allowed to make changes to the main branch(called master) on a public repository unless you are a contributor.

After this the admin will check the changes you have made and if he approves they will be merged with the master branch.

If you are not a contributor:

Create a pull request as suggested by @janos

I'm not sure if you are looking for a GIT tutorial but here is one to start with anyway. http://www.vogella.com/articles/Git/article.html

Upvotes: 1

Related Questions