views:

32

answers:

1

I'm new to Git. Let's say Alice and Bob had been developing their project by using two Git repositories for each. And, Alice at certain times want to set up a new repository to manage their common progress. Do you think what is the best way to replace remote.origin.url in the configuration of Git?

  • to replace by git config --replace
  • to create new repos by git clone MAIN_REPOS
  • or any?
+4  A: 

If they've already got remotes called origin but want the new repository to be called origin then the most logical thing to do is rename or remove the exisiting remote called origin and add a new one.

git remote rename origin old_origin

git remote add origin url://new/url.git

If you don't care about the old origin you can just reset the URL, but you would probably want to do a full git fetch and a git remote prune origin afterwards for tidiness.

git config remote.origin.url url://new/url.git

If you have a very recent git (>1.7.0), you have a remote sub command for this:

git remote set_url origin url://new/url.git
Charles Bailey
Hi Charles,Thank you for the giving me a concise resolution. That's very helpful.
suzukimilanpaak