Search code examples
gitgithubcloud9-idecloud9

How to change git repository using cloud 9


I cloned a github repository using the commands

git config --global user.name "x"
git config --global user.email x
git init
git add -A
git commit -m "message"
git remote add origin /link/
git push -u origin master

now I am in the workspace and want to connect the workspace to a different GitHub repository. How to do that ?

Thanks for your time


Solution

  • If you have already connected to a github reop

    , you need to remove the a remote first,

    Removing a remote Use the git remote rm command to remove a remote URL from your repository.

    The git remote rm command takes one argument: A remote name, for example, destination:

    $git remote -v
    # View current remotes
    origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    origin  https://github.com/OWNER/REPOSITORY.git (push)
    destination  https://github.com/FORKER/REPOSITORY.git (fetch)
    destination  https://github.com/FORKER/REPOSITORY.git (push)
    $git remote rm destination
    # Remove remote
    $git remote -v
    # Verify it's gone
    origin  https://github.com/OWNER/REPOSITORY.git (fetch)
    origin  https://github.com/OWNER/REPOSITORY.git (push)
    

    Note: git remote rm does not delete the remote repository from the server. It simply removes the remote and its references from your local repository.

    Second, I git init new repository.

    Hope it helps