To change the origin of our git repository, we must use the git remote add command, which will allow us to add a new repository from which to perform the clone, pull and push operations. Now we need know how to add a new remote to your git repository.
The git remote add command contains two arguments that we need to know about:
- A unique remote name, for example, «my_software_repo_git»
- A remote URL, which you can find on the clone button of your gitlab repository
To add a new remote repo, you must use the git remote add command on the terminal, in the directory your repository is stored at.
git remote -v
git remote set-url origin firstname.lastname@example.org:leninmhs/sistemaxyz.git
To change repository origin #GIT Ideal for example if they clone a project via https but after days they no longer want to continue placing the key (ssh-key) for each operation
git remote -v git remote set-url origin email@example.com:leninmhs/sistemaxyz.git
The git remote set-url origin will replace your https-based repo with the ssh-based one, in the example using gitlab. If you don’t have the ssh key created, create it with ssh-keygen, copy the value from: .ssh/id_rsa.pub (for linux users) and put it in your gitlab account -> preferences -> SSH keys
With the command git remote -v we can see the remote origins that your Git repository has