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?

coffee-grinder
  • 26,940
  • 19
  • 56
  • 82

4 Answers4

7

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

jshen
  • 11,507
  • 7
  • 37
  • 59
  • 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. – jdd Aug 17 '10 at 01:49
4

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

git remote set-url --push origin git@github.com:leo/repox.git
Bernd Jungblut
  • 349
  • 2
  • 6
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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    It's not preferable to me because it's more junk I have to remember (unnecessarily) and is less direct. – jshen Aug 17 '10 at 17:40
0

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

Dan Davies Brackett
  • 9,811
  • 2
  • 32
  • 54