Git: Push to Server

By Xah Lee. Date: . Last updated: .

How to commit a change to remote repository?

First, commit your changes to your local repository. [see Git: Commit Files]

Then, 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-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's 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 Repo Names

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

git

git FAQ