I am new to Git and am learning as much as I can about it.
The latest thing I would like to know is how to approach this problem: I have a single folder (R
) that I initially set up as a Git repository.
Since setting R
up, it now contains several projects and it is now the case that I have several branches, each reflecting a different project and I don't like it because it feels untidy and disorganised.
As such, I am thinking that the best way to approach the problem might be to create a new repository for each project. (Note that each project is a sub-directory of R
.)
However, I know that creating a new repository means starting afresh (i.e. no branches or previous commits). Second - I'm sure the answer is yes - but I wonder if I can copy across a branch from R
where I used to track changes previously so that I can continue with the new project as a repository as opposed to being a sub-directory of another repository.
So I have two questions:
- Is it a good idea to split each project out into its own repository? (If so, will this affect the overall structure of
R
? The idea is that I stop usingR
as a repository and instead useR\Project1
andR\Project2
, etc, as separate repositories.) - Is there a way to copy a branch from
R
into the new repository?
Note: I am the sole developer/user of these files at present - no others are involved.
R
to the new repositories.git filter-branch
to discard the subdirectories and/or branches not relevant for that clone, and then push to the new remote.I have five branches and it's becoming difficult to easily keep track of which project is which
This sounds like your process could be improved in some way. In my team we have dozens upon dozens of branches in a repo with multiple projects, and there is hardy ever any confusion about which is which. Are the branches focused on one feature/fix, and do they have descriptive names? If you're developing multiple things at once, do you use an issue tracking system?