Switch from remote repository to a local repository with git

1

I'm relatively new to this use of git. The question is:

if I have a local repository, cloned from a remote repository in gitlab, and I want to stop using that gitlab account and use another one, when trying to delete in the local repository with:

$ git remote remove origin

and I add the other remote repository with:

$ git remote add origin2  https://gitlab.com/otro_usuario/otro_repositorio.git

all good. It should be noted that I already have the remote repository created in the other account I want to use. But when I try to upload the local repository to that remote repository added or created new (I already tried to bore the origin, and I also tried leaving it and adding the origin2) it gives me the following error when trying to do the push:

$ git push origin2
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/otro_usuario/otro_repositorio.git/' not found

Checking the remote repositories associated with the local repository gives me the following list:

$ git remote -v
origin  https://gitlab.com/usuario_original/repositorio_original.git (fetch)
origin  https://gitlab.com/usuario_original/repositorio_original.git (push)
origin2 https://gitlab.com/otro_usuario/otro_repositorio.git (fetch)
origin2 https://gitlab.com/otro_usuario/otro_repositorio.git (push)

What am I doing wrong, what is missing, or what I want to do is not possible (keep the change history that I have already made in that repository, but stop using that gitlab account and use another one from the same gitlab) ?

    
asked by Luis Garcia 26.08.2018 в 23:51
source

3 answers

0

I think you are trying to use one for local and another branch for remote, to which you want local you do not need to do push, push and pull are for remote repositories, once you do commit, the action was already done, you can confirm it with:

$ git log

    
answered by 01.11.2018 в 05:32
0

Bad:

$ git remote remove origin
$ git remote add origin2 https://gitlab.com/otro_usuario/otro_repositorio.git

Good:

$ git remote remove origin
$ git remote add origin https://gitlab.com/otro_usuario/otro_repositorio.git

Very Good:

git remote set-url origin https://gitlab.com/otro_usuario/otro_repositorio.git

By files: You can enter the path ".git / config" and edit the url

    
answered by 25.11.2018 в 18:54
0

Hello, the same thing happened to me:

rm -rf .git // esto eliminara todo lo relacionado a tu repositorio git
git init  // inicilizas git en tu proyecto
git remote add origin  https://gitlab.com/otro_usuario/otro_repositorio.git
    
answered by 25.11.2018 в 22:04