Reputation: 9896
Let's say I'm user1
and I have a Github account at http://github.com/user1
. Naturally, I'd set up git locally as so:
origin [email protected]:user1/repo.git (fetch)
origin [email protected]:user1/repo.git (push)
What would I do if I have fetch & push permissions to someone else's repo (let's say user2
) whose repo is located at http://github.com/user2/user2srepo.git
?
EDIT:
Sorry, everyone is right with their answers. I should have clarified that I used to have it set up as origin http://github.com/user2/user2srepo.git
but I wanted to avoid being asked for user credentials every single time I pushed.
Upvotes: 6
Views: 10262
Reputation: 14959
Assuming your github repos are both for the same codebase, you can add them both as remotes to your local repo:
git remote add otherusersorigin http://github.com/user2/user2srepo.git
Then use that alias whenever you need it:
git fetch otherusersorigin
git push otherusersorigin
To do this with no authentication prompt, set up SSH keys for your self according the standard GitHub instructions and get the other person to add you as a collaborator on that repo.
Upvotes: 8
Reputation: 9896
Turns out it's easier than I thought. Thanks to the help of @MattGibson and @eykanal in the comments, I realized that I could just set the remote as follows:
origin [email protected]:user2/user2srepo.git (fetch)
origin [email protected]:user2/user2srepo.git (push)
The difference here being that the user is setup as user2
and not my own username. I mistakenly thought I'd need to enter user2
's credentials, but that's not the case if I've been set as a collaborator on user2srepo
.
For those interested, the command to set this if you already have the remote set is as follows:
git remote set-url origin [email protected]:user2/user2srepo.git
Upvotes: 4
Reputation: 27077
If you have write permissions to that repo, simply clone that repository and commit directly to it. You don't need to go through the forking process.
Upvotes: 2