I'm trying to expand on a project I previously worked on while keeping the original unchanged. How would I do this? Was told to simply clone the original git repo to another one but it's unclear to me whether once I make changes to the code if this will affect the original repo and project.
4 Answers
Unless you explictly push to the original, no local changes will apply to the original. That is one of the fundamental features of git: Only push
will actually change a remote repository. Any commit/branch/revert/... is purely local until you distribute those actions via a push (or a pull from the other side).
If you want to make sure that you don't accidentally push to the original, you can remove the remote after you cloned it (of course that also means you won't be able to pull new changes from there until you re-add it).
Alternatively you can keep the remote (so you're able to keep pulling), but configure the push URL to something invalid, as described in this question.

- 302,674
- 57
- 556
- 614
After cloning a repo, there are two distinct repos located at two different places. Nothing you do on any of them will affect the other. The only relation between the two is the cloned repo will have one of its remotes set to point to the original repo — named origin
. You can list them with git remote -v
in the cloned repo — -v
is for --verbose
, shows the url.
Without further settings, the only way the clone repo can effect the original repo is when you do a git push
from the cloned repo.
You can even cut the tie by removing the origin
remote from the cloned repo with git remote remove origin
. Now there is no where to push to. But this is usually not what you want. When the original repo has changes (fixes, updates, ...), you will mostly want those changes in the cloned too. This is when you might do a git fetch
or git pull
in the cloned repo to bring over those changes.

- 536
- 1
- 5
- 22
You can just clone a repository and then make a new repository from the place you cloned the original one. Then you can clone that new repository somewhere else and you can make changes there. But why do you need 2 repositories? Consider using branches

- 723
- 4
- 19