michaelsgx
michaelsgx

Reputation: 59

How to know the origin of the remote repository?

I am trying to update the codes in ssh://[email protected]/~/git/idating1.git, which is given by openshift for project idating1. But due to some reasons, my mac cannot setup rhc properly. I successfully git clone the source code. How can I push changes of the code to ssh://[email protected]/~/git/idating1.git? I don't know what the name of the origin is.

Upvotes: 1

Views: 1204

Answers (2)

jthill
jthill

Reputation: 60275

Repo's don't have intrinsic names -- they don't even have intrinsic urls. There is only how you refer to them this time.

You can see what names a remote repository has for its own remotes with git ls-remote u://r/l, but I'm pretty sure there's no way to discover what url's it uses for them.

What name you use for a remote is utterly arbitrary. origin is just a handy conventional name for the remote set up by clone.

You don't even need a name at all; for one-off pushing and fetching you can use the url directly.

Upvotes: 0

VonC
VonC

Reputation: 1323953

You need git remote -v | grep /part/of/the/url to get the name of the remote upstream repo. (See git remote)

You also can see it in a git config --local -l

If you don't want to do a grep, git config can do it for you:

git config --get-regexp remote.* b2d

remote.origin.url https://[email protected]/VonC/b2d.git
       ^^^^^^
          |
          --- name of the remote, for an url including "b2d"

That will grep for any remote.* key, with any value including part of the repo url (here, just its name in this example)


If git remote -v returns nothing, then no remote is set locally.
To add one:

cd /path/to/local/repo
git remote add origin /url/to/remote/repo
git push -u origin master

Upvotes: 2

Related Questions