Push from one repo to another - Git

moesef picture moesef · May 20, 2013 · Viewed 10.6k times · Source

I have a repo on my local computer. I want to develop and make changes in a branch on my local repo and then push these changes for testing to a repo on a server that I can ssh into. How do I do this? I have never pushed/pulled from the local to the server, only pulled down through SSH from my bitbucket account to either my local computer or remote server.

Thanks, Mo

Answer

Klas Mellbourn picture Klas Mellbourn · May 20, 2013

You can create a repo on the server by logging in to it, and do a git init --bare.

Then on you local computer you

git remote add serverrepo <url to server repo>

Now you can push and pull to the serverrepo, and to origin (bitbucket?).

You can push your branch to just the serverrepo if you wish:

git push -u serverrepo branchname

If you need to "publish" the repo on the server somehow, you can follow this guide.