Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to contribute to someone else's repository?

Tags:

git

github

I have a friend who has a repository in his GitHub account. I want to contribute (pull/push) to the master branch (the only branch) on that repo directly.

How would I go about doing this directly on the command line using git?

like image 358
sparta93 Avatar asked Sep 23 '15 22:09

sparta93


3 Answers

Since you specified that you want to push directly to your friend's repo, your friend needs to add you as a collaborator in the repo settings.

However, given your inexperience with git, it would be better to take the indirect approach: fork the repo and use pull requests to move your changes into the main repo.

like image 164
Falk Schuetzenmeister Avatar answered Oct 17 '22 00:10

Falk Schuetzenmeister


The right way would be to fork his repository, do your work and then create a pull request. Then he could review it and decide to merge it into his work. Here's a good description: https://guides.github.com/introduction/flow/index.html

Edit: added a link to github.

like image 5
Zepplock Avatar answered Oct 17 '22 00:10

Zepplock


I'm summing up everyone's answer.

  1. Fork your friend's repository.
  2. Fire up your terminal and type git clone {URL}.
  3. Use this command to create a branch: git checkout -b new_branch.
  4. Create a new remote for the upstream repo i.e. the link of original repo with the command: git remote add upstream {URL}
  5. Do whatever changes you want in your local machine.
  6. Fire up your terminal again and type git add {file name} or git add . if you want to add all files.
  7. Then type a message git commit -m "message"
  8. Create a branch: git remote add upstream {URL of friend's repository that you have forked}
  9. For confirmation: git remote -v
  10. git push Here you have to give your username and password.
like image 4
Ashutosh Dash Avatar answered Oct 16 '22 23:10

Ashutosh Dash