I cloned a directory to my local machine, but I want to delete it without affecting the remote directory.
I am inexperienced with git.
Any suggestions?
CodePudding user response:
TL;DR It depends. :)
Scenario 1: local sandbox you never plan to push from
If you are cloning that repo to use it locally but never plan to push changes from it, go ahead and delete what you want, you're working in a local copy, it will have not effect.
If you cloned that repo by accident or no longer need it, again, delete merrily, it's just a local copy.
Scenario 2: sandbox that you plan to use to modify the remote in other ways
If you are cloning that repo to make changes in it that you plan to commit and push later, then it's best not to delete stuff out of it unless you actually mean to remove it from the remote too, because you will constantly have to be careful not to commit that deletion.
Of course the full answer is more complicated...
If you delete the files/directories locally, you've only deleted them locally. Make sure you never commit that deletion, and then you're sure you'll never affect the remote.
But if you make changes and then want to use
git add .
, you'll accidentally commit that deletion. And every time you do agit diff
orgit status
, it's tell you about having deleted those files.There are ways to tell Git to ignore the fact that some files are gone/changed, and I used to think it was fine to use them, but I've been convinced by discussions on other questions here that it's not a good idea.
All this to say, TL;DR take 2 it's probably best if you don't delete those files/directories.