Git: Push to Server
How to commit a change to remote repository?
First, commit your changes to your local repository. [see Git: Commit Files]
cd to the local project directory.
git push url
This will push your local repository to the remote git server.
Associate a Name with a URL
Typing a URL everytime is tediouos. So, there's a way to associate a name with a URL, and make the name as default. So, you just type
git push and it'll be pushed to the default remote server.
git remote add name url
- Associate the name name to a remote source url.
# cd to your project dir cd ~/git/xah_emacs_init/ # associate a name to a remote server, for the git project of current dir git remote add gh https://github.com/xahlee/xah_emacs_init.git # push code to the url associated with the name “gh” git push gh
The Name “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.
You can see the list of naming in the directory 「.git/config」 of the project directory. Example:
[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