Git: Associate a Name with a URL
Associate a Name with a URL
- you can associate a name with a URL. (convenient, save typing.)
- you can make a repo name as default for git push or git pull commands.
git remote add name url
-
Associate the name name to a remote source url.
# cd to your project dir cd ~/git/xah-fly-keys # associate a name to a remote server, for the git project of current dir git remote add xyz https://github.com/xahlee/xah-fly-keys # push code to the url associated with the name xyz git push xyz
What is Git “origin”
When you clone a project, that source is automatically given the name origin .
When you do git push or git pull without a url or name, “origin” is assumed.
List Git Remote URLS
cd to the repo, then
git remote -v
List Git Repo Names
You can see the list of naming in the directory
.git/config
of the project directory.
Example of a local git config file:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = https://github.com/xahlee/xah-fly-keys.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master pushRemote = origin