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?
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.
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.
I'm summing up everyone's answer.
Fork
your friend's repository.git clone {URL}
.git checkout -b new_branch
.git remote add upstream {URL}
git add {file name}
or git add .
if you want to add all files.git commit -m "message"
git remote add upstream {URL of friend's repository that you have forked}
git remote -v
git push
Here you have to give your username and password.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With