How to 'git push' to a repo that was cloned as read-only onto my team's staging server
Asked Answered
S

4

10

I cloned a repo using its GitHub read-only URL onto my team's staging server. I made some changes there to the config files.

I'd like to change the repo clone on the server to be read-write, so that I can 'git push' the config file changes.

How do I do this?

Or is there a better 'best practice' way to deal with this scenario than committing from the staging server?

Spoofery answered 17/8, 2010 at 0:44 Comment(0)
P
7

open up .git/config in your favorite text editor and change the remote url to the read+write url that github shows you.

Progression answered 17/8, 2010 at 0:59 Comment(1)
This is the canonical solution. If you're sure you want your stage server to have push access to the github repo, you probably want to do this. It's a very simple change.Mythologize
S
4

if you only want to set the push url you can use the --push option

git remote set-url --push origin [email protected]:leo/repox.git
Snead answered 19/12, 2011 at 19:43 Comment(0)
K
1

From GitHub Working with remote help page:

Changing a remote’s URL

There is no direct command to change a remote’s URL, so you will usually run git remote rm followed by git remote add to change a URL.
You can also edit the repo’s .git/config file directly to change the URL without re-fetching the remote.

I would recommend (see this SO question):

git remote set-url origin git://new.url.here

Using git command is always preferable to modifying directly a git config file manually.

Kilogrammeter answered 17/8, 2010 at 4:7 Comment(1)
It's not preferable to me because it's more junk I have to remember (unnecessarily) and is less direct.Progression
W
0

I'd take a diff from the staging server and apply it in a development environment via patch(1).

Witless answered 17/8, 2010 at 0:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.