How do I move my local Git repository to a remote Git repository

后端 未结 8 1599

I have various Git projects that are on my local machine. I have a server that I would like to use as my remote Git Repository. How do I move my local Git Repositories (Pro

8条回答
  •  感情败类
    2020-12-07 09:41

    If you have a stand-alone local working tree repository (a folder with a ".git" folder inside) that you want to add a remote to:

    1. Create a new empty repository in the remote.
    2. In the local repository, set the new remote as the origin:

      cd localrepo

      git remote add origin REMOTEURL #(verify with git remote -v)

    3. Push all local branches to the remote, and set each local branch to track the corresponding remote branch:

      git push --all --set-upstream origin #(verify with git branch -vv)

    4. Push all local tags to the remote:

      git push --tags origin

    At this point the local repository will act just like it had been cloned from the remote.


    If you have a bare local repository (a folder with a name ending in .git) that you just want to copy to a remote:

    1. Create a new empty repository in the remote.
    2. In the local repository, push all of its branches to the remote

      cd localrepo.git

      git push --all REMOTEURL

    3. Push all local tags to the remote:

      git push --tags REMOTEURL

提交回复
热议问题