It's always a good idea to keep a copy of your repository on an external server in case your local copy is deleted. There are two general ways you can go about this:
- Create your application and Git repository on your DreamHost server. Then, you can push to GitHub
- Create your application and Git repository on your home computer. Once it's ready, push the repo to your DreamHost server.
These two options are detailed below.
Pushing your DreamHost repository to GitHub
If you've developed your site on your DreamHost server, it's recommended to put a copy on GitHub for two main purposes:
- This creates an external backup of your code, and
- It makes future collaboration with other developers much easier.
Follow these steps to push your repository to GitHub
- Sign up at GitHub.
- Create a public or private repository in your GitHub account without a README file.
- Once created, github.com shows you several commands to run to push your git repository to their servers.
- Log into your DreamHost server via SSH and navigate to your application folder where you set up your git repository.
- Run the following command to push your app to GitHub:
The word 'origin' is just an alias. It can be named anything you want. But this alias name will be used when you push your content to github.com as shown in the next step.
'repo_name' is the name of the repository you created at github.com. Make sure .git is at the end.
[server]$ git remote add origin https://github.com/github_username>/repo_name.git
- Push your repository to GitHub
[server]$ git push -u origin master
- View the following link for details:
- Visit your repository at github.com and you'll see that all files have been added.