Reputation: 289
I had a repository on GitLab which I also published on GitHub.
As of now all the Git commands I am using are making changes on GitLab. However, I want those commits on GitHub.
I tried the command:
git remote set-url origin [email protected]:repo-url
Can someone suggest me how to set the URL so that commands would work on GitHub and not GitLab?
Upvotes: 8
Views: 11429
Reputation: 5038
Check what the repository is linked to with the command:
git remote -v
If it is linked to multiple url's that may be the issue. Try to remove the unwanted url with the command:
git remote rm <destination>
Then check again which repos are linked, by running git remote -v
once more.
Upvotes: 2
Reputation: 2270
If you want to use both GitHub and GitLab:
git remote add github <your-github-url> # create a remote for GitHub
git remote add gitlab <your-gitlab-url> # create another remote for GitLab
git push -u github <local_branch_name> # set the default upstream to GitHub
If you want to change your remote URL from GitLab to GitHub:
git remote set-url origin <your-github-url> # use GitHub as your (only) origin
See also "How to change the URI (URL) for a remote Git repository?" and "What exactly does the “u” do? “git push -u origin master” vs “git push origin master”".
Upvotes: 27