Just a note to myself, as I do not do this often enough to remember.
If you have a local GIT repository (which has no remote so far, as it was only used for local development so far) and want to push it out to a remote repository, and make that repository the default for push and pull operations, here is how it's done.
This requires GIT 1.7, and assumes the following:
- The local branch tobe pushed is
master
- The remote repo is accessible via
ssh://user@example.com/GIT/project.git
and already contains a freshly created, bare
repo
First, add a remote to the local repository.
$ git remote add origin ssh://user@example.com/GIT/project.git
This, by itself, does not do exacly much except to add a remote repository to your local repo config. The remote repo is called origin
, which is the default name git chooses if you git clone
from a remote repo. The remote repo is not associated with any local branches yet.
Second, push the accumulated local commits to the remote repo, designating the remote as the default for future push/pull operations.
$ git push --set-upstream origin master
This will push the local master branch to the remote origin, creating a master branch there as well, and ties origin to the local master branch as the default for push and pull. Future git pull
and git push
will work without any specifications of local or remote branches.