Setting up Git repo on Dreamhost

programming, Uncategorized

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:

https://help.dreamhost.com/hc/en-us/articles/115000675027-FTP-overview-and-credentials#Finding_your_FTP_server_hostname

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

Heroku on Windows 7

heroku, programming, Windows

Prerequisites

Git installed and on PATH

Installation

Sign up for a Heroku account.  Note the user email address and password.

Download and install the Heroku Toolbelt. (see https://devcenter.heroku.com/articles/quickstart)

Even if you have your own version of Ruby, it’s better to have the Heroku Toolbelt install its own copy (default behavior).  Normally it will be installed in the “ruby-1.9.3” (may be different as new versions are used by the time you read this) subdirectory which is sibling of “bin” and “data”.

Make sure heroku.exe is on the PATH:

C:devprojects>heroku version
heroku/toolbelt/3.10.1 (i386-mingw32) ruby/1.9.3

Run “heroku login” to generate a key-pair under %HOMEPATH%.ssh

Project setup

Create a git project (either via “git clone” or “git init“).

CD to your project root and run “heroku create” to setup Heroku and add the hooks into your project.

Follow instructions on how to set up your app’s auxiliary files, such as adding a “Procfile” file to your project root and adding properties files.

Project deployment

Deployment is normally done simply by running “git push heroku master” to push your code up into Heroku’s Git repo (that was set up by “heroku create” earlier).

One possible error at this point is:

C:devprojectsherokuruby-sample>git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.

I found that git looks at %HOME%/.ssh for SSH key files, but normally %HOME% isn’t set.  So modify your environment variables to add this setting:

set HOME=%HOMEPATH%

After the above, “git push” should work.  If not, then there may be a discrepancy between the %%HOME%.sshid_rsa and %HOMEPATH%.sshid_rsa.pub files and what the SSH keys settings are in your Heroku account.