Git Getting started with Git Sharing code


To share your code you create a repository on a remote server to which you will copy your local repository.

To minimize the use of space on the remote server you create a bare repository: one which has only the .git objects and doesn't create a working copy in the filesystem. As a bonus you set this remote as an upstream server to easily share updates with other programmers.

On the remote server:

git init --bare /path/to/repo.git

On the local machine:

git remote add origin ssh://username@server:/path/to/repo.git

(Note that ssh: is just one possible way of accessing the remote repository.)

Now copy your local repository to the remote:

git push --set-upstream origin master

Adding --set-upstream (or -u) created an upstream (tracking) reference which is used by argument-less Git commands, e.g. git pull.