Establish a remote Git repo

Posted in tech; tagged with git, tips

HOWTO: You’re seeking a usage pattern not unlike Github where you and perhaps others will clone or checkout the remote (upstream) repository:

On remote machine or some file system

Follow convention - give the remote repo directory a .git extension:

mkdir theproject.git
cd theproject.git
git init --bare

In your local work space

mkdir theproject
cd theproject
git init
echo "# The Project" >>
git add *
git commit -m "Initial commit"
git remote add origin remotehost:theproject.git

Note that “origin” is just a label, a name. You could call it whatever, but origin seems to have become a convention. Finish:

git push -u origin master

Which will report:

Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To myhost:repo/theproject.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

All done.