Create an empty repo
Create an empty repo off of /home/username where username is your user name.
The following will create an empty repo named “myrepo” in the subdirectory /home/username/myrepo.git
cd ~
git init --bare myrepo.git
Adding content
Go to where the source code are and initialize a git repository. Then add the files and configure as necessary:
git init
git add ...
git commit ...
Configure a remote repository to map to the repo created earlier in order to push contents to:
git remote add dreamhost ssh://username@server.dreamhost.com/home/username/myrepo.git
The above sets up a remote repo called “dreamhost” that tracks the repo created above. The URL component ssh://username@server.dreamhost.com
indicates how to access the server where the repo is. The user name and server names can be found by following the docs from Dreamhost:
Finally, push the change up:
git push -u dreamhost master
Pulling content
Most likely on a different machine, use git clone
to pull content and start tracking changes:
git clone ssh://username@server.dreamhost.com/home/username/myrepo.git
Cloning into 'myrepo'...
username@server.dreamhost.com's password: xxxxxxxxx
remote: Counting objects: xx, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total xx (delta 1), reused 0 (delta 0)
Receiving objects: 100% (xx/xx), 3.28 KiB | 3.28 MiB/s, done.
Resolving deltas: 100% (1/1), done.
The URL component ssh://username@server.dreamhost.com
indicates how to access the server where the repo is as is the case before. The path /home/username/myrepo.git
is the path to the remote repo that you create in the first step above.
Now you can use git add
, git commit
, and git push
to add content:
git add ...
...
git commit
...
git push origin master
Or, for a specific branch (mybranch
in this example):
git checkout -b mybranch
git add ...
...
git commit
...
git push origin mybranch