So what if you want to add Heroku as a remote to a repo you already have on your machine, or maybe something went catastrophically wrong and you had to blow away a repo and now want to put your push setup back like it was.

I'll save you from having to go dig around Heroku's docs or stackoverflow. Here ya go:

heroku git:remote -a <app-name>

Where app name is what you called your app when you created it. You can find this under settings in Heroku if you're not sure or cant remember.

A long time ago in a galaxy far far away, we used to use FTP to upload files. Things like coda, filezilla, Dreamweaver ect. That was when the west was young and I was a baby dev. Today, there are much more robust alternatives. There are tools like Capistrano, Rocketeer, and Deployer for those who want ultimate control and prefer to do it themselves. Then there are other solutions like for fully integrated solutions that remove some of the legwork.

Every once in a while though, You may just need to throw a quick file up on the server ( or many of them ). You may need to download a bunch of stuff or upload a bunch of stuff. In such cases most people just reach for there handy dandy FTP client again. While this solition works, it is very slow. Hence why i'm writing this post. I had to upload a bunch of images the other day to a site with no deployment system in place. I ended up using coda to upload and almost shot myself. Even on my super fast internet the process was a crawl at best. So enter SCP to save the day.

What is SCP?

SCP is a secure copying protocol that is related to SSH. It is much quicker than FTP so let's take a look at how it works.

Downloading a file from remote to local
#Make a local directory to test with
mkdir ~/Desktop/scpTest

#Copy the file from remote to local
scp -P 7822 root@ ~/Desktop/scpTest  
Uploading a file from local to remote
scp -P 7822 ~/Desktop/scpTest/ root@  

Notice that with these two the order of things is just reversed. In the first example, downloading a file, you specify the server first. In example two, uploading a file, you specify the file to upload first. Also take note of the -P flag to specify a custom port.

If your host required a custom port and you don't specify the port with the -P flag then the default port will be attempted and the connection will be unsuccessful.

Uploading entire directories from local to remote
#Copies the local directory scpTest to the scpDemo directory on remote.
scp -P 7822 -r ~/Desktop/scpTest/ root@  

The thing to note here is just the inclusion of the -r recursive flag. As you would imagine copying directories from remote to local can be done in the inverse way as we did with files above. Just don't forget the recursive flag.


SCP is faster and more secure than FTP. In addition, it's more convinient once you get the syntax down. So when you cant use a git based deployment solution and you have to transfer some stuff manually, don't hesitate to stay in the terminal.

Until next time. Same Bat time, Same Bat channel.

I have been clueless up until recently about how to install things with composer in the same way that it is done with NPM. Its amazing that something so small is so easy to do yet can still remain mysterious. Perhaps because in the grand scheme of things, it is a minute detail compared to the monstrosity of knowledge that there is to learn, when it comes to being a developer.

In any case. Here is the one liner that does this:

composer require <vendorname/packagename>

When prompted for a version just enter it or defer to dev-master.

The end

So you may be thinking, why would I want to do that? A: It saves a lot of time when you can just do everything right from 1 place. It's a convinience. So how does it work? ( Btw im going from CentOS to Mac. It should be pretty similar though on any *nix system.

From remote to local.

scp -P 7822 root@your_remote_ip_here:/var/www/ghost/content/data/ghost-dev.db /Users/someUser3378/Desktop/gb/ghost-dev.db  

Make sure you are not logged into the server when you run the above command.

My host, A2 Hosting requires that capital P flag there and the port since they must have it set to something other than the default. The above will move the remote ghost-dev.db file to the local ghost-dev.db on my desktop. Pretty cool huh? Next up, local to remote.

From local to remote.

scp -P 7822 ~/Desktop/localDir/someFile.txt root@your_remote_ip_here:remoteDir/  

The Database import

Before doing this, I suggest you make a backup of your production db. So this is more of a replace than an import. You just scp the db you want down and place it into your local Ghost install in the ghost/content/data directory and just replace the local db you are aiming to overwrite. I personally just preface the local db name with an underscore if it already exists. That way I can revert back if some issue occurs.

Let me know if you have any questions or tips!