I’m new to git and github and I’m struggling to figure out what’s going on with git in cmd. I’ve just made lots of commits and I’m done working on one of my repos (locally and pushed to GitHub).
I now want to work on another repo locally for which I have a repo on GitHub, but I’m not sure how to stop the connection between my local machine and GitHub for the repo I’ve just finished working on. Is there a way to break the connection in cmd between the local repo and the GitHub repo? A proper way to close it?
Subsequently, if I want to move to another project, how do I do this? Would I need to break the connection then start from scratch? i.e.:
# after breaking previous link start again with:
git init
git remote add origin URL
git push -u origin master
# make changes to files then:
git add .
git commit -m "message"
git push
>Solution :
Is there a way to break the connection in cmd between the local repo and the GitHub repo? A proper way to ‘close’ it?
You can break the connection between your local and the remote repository by using the git remote remove command, but you will not gain anything by doing that.
No, you do not need to "close" a repository if you don’t work on it. You just stop working on it.
You can also just delete your local copy of the repository if you don’t plan on working on it any further (assuming that you’ve pushed all relevant changes to the remote).
Subsequently, if I want to move to another project, how do I do this? Would I need to break the connection then start from scratch?
You don’t need to do anything if you don’t break the connection between the local and the remote repository. Just continue working on the other project where you left it the last time.
Yes, if you start a new other project, you could use git init to create a new Git repository for it.
I’m assuming you are using separate directories for each project. Don’t use the same directory for multiple unrelated projects with their own Git repositories.