Pushing your local Git repository to a DreamHost server — Linux & Mac OS X
source link: https://help.dreamhost.com/hc/en-us/articles/216445197-Pushing-your-local-Git-repository-to-a-DreamHost-server-Linux-Mac-OS-X
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pushing your local Git repository to a DreamHost server — Linux & Mac OS X
Overview
These instructions assume that you've created your application or website on your home computer, and then used Git to create a local repository.
The following steps describe how to push your local Git repository to your DreamHost server. In this way, you can develop your website on your home computer and push the changes to your live DreamHost website.
Pushing from Linux or Mac OS X
- On your local computer, navigate to your user's ~/.ssh directory:
[local ~]$ cd ~/.ssh
[local ~]$ mkdir ~/.ssh
- Set up SSH keys by running the following command:
[local ~]$ ssh-keygen -t rsa -b 4096 -C "DreamHost Git repo"
- Enter a name for the file when prompted, such as dreamhost-git-key.
- When prompted to enter a password, click Enter twice to skip.
Two new files are created in your user's .ssh directory:
[local ~]$ cd ~/.ssh [local ~]$ ls -la dreamhost-git-key dreamhost-git-key.pub
- Use the following instructions to copy your public key into your DreamHost server's authorized_keys file.
To run the following commands, you need the name of your DreamHost server and the user/pass your website is under. View the following articles to locate this information:
[local ~]$ ssh-copy-id -i ~/.ssh/dreamhost-git-key.pub [email protected]
[local ~]$ cat ~/.ssh/dreamhost-git-key.pub | ssh [email protected] "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
You may receive the following error when running this command:
mkdir: cannot create directory `/home/username/.ssh': File exists
This simply means the /.ssh directory already exists on the web server. If you see this, remove the portion of the command that creates the directory and run again. For example:
[local ~]$ cat ~/.ssh/dreamhost-git-key.pub | ssh [email protected] "cat >> ~/.ssh/authorized_keys"
- Log into your DreamHost server via SSH:
[local ~]$ ssh [email protected]
If you receive an error when attempting to log in, you may need to use ssh-agent. See the following article for more information:
- Confirm your key has been added to the DreamHost server by running the following (this should output your key):
[server]$ cat ~/.ssh/authorized_keys
- Create a new directory for your new remote repository on your DreamHost server. If this code is meant to replace your existing website, you could name it the same as your website ending in .git.
Since this is a remote repository and not a working repository, the directory name you create must end with .git. You can then checkout this repository in the future to work on it.
[server]$ cd ~ [server]$ mkdir example.com.git [server]$ cd ~/example.com.git [server]$ git init --bare [server]$ exit
- Navigate to your git repository on your local computer, and then push to the remote repository on your DreamHost server. Make sure to change user and server to your actual DreamHost username and servername:
[local ~]$ git remote add dreamhost ssh://[email protected]/~/example.com.git [local ~]$ git push -u dreamhost master
Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 200 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To ssh://[email protected]/~/example.com.git * [new branch] master -> master
How can I confirm my repository was correctly pushed to my DreamHost server?
If you run git status in the ~/example.com.git directory, the following error appears:
[server]$ git status fatal: This operation must be run in a work tree
This is because it's a 'bare' repository, not a working directory you can use. You could clone this remote repository into a working Git repository. This allows you to view the files that were pushed to the server.
- Log into your DreamHost server via SSH.
- Clone the repo to a new location by running the following in your user's directory:
[server]$ mkdir ~/cloned.example.com.git [server]$ git clone ~/example.com.git ~/cloned.example.com.git [server]$ cd ~/cloned.example.com.git [server]$ ls -la
How can I use Git for web development?
View the following article for instructions on how to push changes on your local computer to your live website.
See also
Did this article answer your questions?
Recommend
-
3
Pushing your local Git repository to a DreamHost server — Windows Overview This article assume that you've created your application (website) on your home computer. The steps below...
-
5
Pushing your DreamHost Git repository to GitHub Overview 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 a...
-
11
How do I import my old host's email to my DreamHost mail server? Overview This article explains how to import an email backup you created at your old hosting provider into your Dre...
-
13
Certificate domain mismatch error when connecting to a DreamHost mail server Overview You may receive a "domain mismatch" warning or an error when connecting to a DreamHost mail se...
-
7
-
26
How to cache Gradle build dependencies to a local Maven repository
-
5
Remotely access your Linux server’s GUI from your local network In this post, I’ll describe how to enable remot...
-
11
Getting permission denied for SCP over SSH server to local Asked 8 years, 5 months ago ...
-
3
Tired of pushing to test your .gitlab-ci.yml? Run gitlab pipelines locally as shell executor or docker executor. Get rid of all those dev specific shell scripts and make files. Table of contents Installation
-
2
Git is a powerful and popular version control system that helps you manage your code history and collaborate with other developers. However, over time, your local repository may accumulate some unwanted files and branches that clutter your workspa...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK