Skip to content

Instantly share code, notes, and snippets.

@ItsMeAra
Last active February 22, 2016 19:06
Show Gist options
  • Save ItsMeAra/4422067 to your computer and use it in GitHub Desktop.
Save ItsMeAra/4422067 to your computer and use it in GitHub Desktop.
Use SSH to set up your own Git repos on your server. http://net.tutsplus.com/tutorials/tools-and-tips/ssh-what-and-how/
$ ssh user@example.com
$ cd /path/to/repo
$ git init
$ git checkout -b staging
$ git checkout master
$ exit
$ cd /local/repo
$ git init
$ git add .
$ git commit -am "some message"
$ git remote add origin user@example.com:/path/to/repo
$ git checkout -b staging
$ git push origin staging
$ ssh user@example.com
$ cd /path/to/repo
$ git merge staging
Essentially what is happening here is you are logging into the server, changing to the desired repo path,
creating a repository and adding a “staging” branch which you can push to from your local machine.
Then, you are creating your local repo and a corresponding “staging” branch on your local machine,
and adding files to track to the repo. Next comes an initial commit. You are then adding the remote repository
as an alias of “origin”. Next, you are pushing the local staging branch to the “origin” alias’s staging branch.
Finally, you are ssh’ing back into the server and merging the “staging” branch with the default “master” branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment