Push from one repo to another - Git

10,989

Solution 1

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.

Solution 2

If you want to avoid the command line and are using Atlassian SourceTree do Repository->Add Remote on the source repository and then you can push your changes to the destination.

Share:
10,989
moesef
Author by

moesef

Mohammad Samman recently earned his B.S. in Bioengineering from UC San Diego, a top ten school for this degree. Now that he has graduated, he is working to gain some good experience in the Biotechnology industry. Mohammad Samman is happy with his current position at iHear medical, but is always open to networking and making industry connections. While not at work, Mohammad Samman is teaching himself various programming languages to have some experience in web and mobile development, which Mohammad feels are necessary skills to for anyone in the technology field, and believes it will help him in pursuing his goals of one day starting his own tech company. Mohammad Samman plans to one day return to school to gain a dual Master's in Computer Science and is excited to for a long and fulfilling career.

Updated on June 18, 2022

Comments

  • moesef
    moesef almost 2 years

    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

  • moesef
    moesef almost 11 years
    after following the tutorial, making a bare repo, I try to add the remote repo and get "fatal: not a git repository". this is the command I am using git remote add web ssh://xx.xxx.xxx.xxx/home/mo/dev.git
  • Klas Mellbourn
    Klas Mellbourn almost 11 years
    Have you changed directory to your git repo on the local machine?
  • moesef
    moesef almost 11 years
    I didn't... that was the problem. But now the post-receive doesn't seem to work correctly. I'll keep at it and try to work it out. Thanks for the help.