简体   繁体   中英

Migrating a GIT Repository to the Cloud

I am currently working in a repository that is stored on our locally hosted network at:
http://git.**company**.internal/Development/repo.git

The company is in the process of moving everything to the cloud instead of hosting everything ourselves. It seems like a convenient time to move the GIT repository to the cloud as well. It's been a while since I've done much besides pushing, pulling, and merging to the repo - so I don't want to mess this up. I want to create a separate repo stored based in the cloud and change my local directory to point to the new repo instead of the old one.

As I said, I am fuzzy on the GIT commands to do this - so it may just be simple.

My idea is - I need to fork the current repository, cd into a directory that is stored on the cloud, clone(?) that repository, and then pointing my working directory to the new one is a mystery to me.

I'm sorry if this is confusing, my understanding of GIT is lackluster. I can provide clarification on what I am looking for if this isn't clear.

It is unclear what you're trying to do.

The company is in the process of moving everything to the cloud instead of hosting everything ourselves. It seems like a convenient time to move the GIT repository to the cloud as well

Are you moving the repo to the cloud, or it done for you? Where is your git repo now? Surely you don't have it on your local drive only, as it for the most part defeats the purpose of git...

  • If someone else is moving your git repo, all you have to do is add a new remote to your current git repo (and may be remove the existing one). You can add it via a cli:

     $ git remote add <name> <url>

    You can read the rest here: https://git-scm.com/docs/git-remote

  • If you're the one who's moving the repo, then you need to do the following:

    1. create a repo on your cloud (be that GitHub, Bitbucket, GitLab etc)
    2. add a new remote to your existing repo pointing to the new repo
    3. switch to the master (or whatever main branch you have) locally
    4. push to the new remote:
     $ git push <new remote name> master
    1. (optionally) remove the original remote

From that point onwards, just do what you've been doing before, just push to and fetch from the new remote.


(Shameless plug) You can also you Git Extensions to help you visualise your repos and save you fro remembering all these git commands.

For Github:

  1. Create new repository in Github and don't create a readme file.

  2. Clone the mentioned repository from your server to your local machine.

  3. git remote add origin <url> (url of the new github repo)

  4. git push origin master

Note: you shouldn't commit because you probably already have commits in this repository, just add a new remote I called it origin and push it to the Github server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM