Monday, August 28, 2017

Change the git repository you are working on

When you need to change the git repository you connect to, here is what you can do:

1. See current repository
git remote -v
you will get something like this:
origin  https://github.com/<your-name>/<repo-name>.git (fetch)
origin  https://github.com/<your-name>/<repo-name>.git (push)
2. Remove current repository
git remote rm origin
Optionally you can run the command at step 1, to see you don't have any repository connection.
3. Connect to new repository
git remote add origin https://github.com/<your-name>/<new-repo-name>.git
If the new repository is empty you can push everything:
git push -u origin master
for other things you can execute:
git status
and continue from there.


No comments:

Post a Comment