Home > OS >  Cloning a Secondary Repo and NOT having it track on Github
Cloning a Secondary Repo and NOT having it track on Github

Time:10-26

Bear with me as the answer may seem simple (it does, intuitively, to me, but I have to double-check).

I am a junior dev at a company and have already cloned our repo from GitHub and set up tracking, so my code and branches are connected to our company's source repo. Great.

But I am taking a styled-components course so that I can be more useful when helping with styling changes, and I want to clone a secondary version of the repo to my computer that will not track with the source - just a private, locally-run version where I can practice styling (and another coding, if necessary). Is it as simple as cloning the repo again, in a different area of my computer, and not setting up tracking? Or will there be an issue because I already have this same repo cloned and following in another area of my device?

I know I can set up a testing branch for myself and delete it without ever merging it - but I'm still curious.

Thanks in advance!

CodePudding user response:

As you mentioned, you could create a branch for this use case, but also another way is to create a fork from the original repo, which is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project. That would be better than cloning it two times.

CodePudding user response:

I think, to achieve your objectives, you can:

  1. Clone the repository in another folder - just be sure to play with it and never push it...
  2. Make a fork - this will create your own copy of the repository, and you will be able to commit, push, create branches and so on. You will be able to even create pull requests if, at some point in the future, you desire to add some of the stuff you have been playing to the main repository
  3. Create a branch for your experiments. This way you will be able to isolate your changes without doing any harm to the main code. This means you don't need to clone the repository again - you can just switch branches whenever you need.

I think you can judge which one fits best for you. Usually, when I do proof of concepts, I choose either to create a branch or a fork (depending on the amount of work needed), but it is up to you...

CodePudding user response:

[I] want to clone a secondary version of the repo to my computer that will not track with the source...

If you want a separate copy of the repo that "is not tracked" the you can clone the repo to another directory and remove the .git/ directory that is downloaded as part of the clone.


will there be an issue because I already have this same repo cloned and tracking in another area of my device?

No, but be aware that any changes you make there will not be reflected within the repo, as tracked by git.


I also know I can set up a testing branch for myself, and delete it without ever merging it - but I'm still curious.

You can create a branch, and check the branch out, with:

$ git branch <branch-name>
$ git checkout <branch-name>

If you want to complete wipe away and delete your local changes you once are done experimenting you can run:

$ git reset --hard HEAD

But be warned that this will wipe away your local changes.

  • Related