1

I don't know if this is a stupid question. Since now GitHub allows unlimited private repositories and I often write reports with LaTeX, I'd like to push my local repositories to GitHub as backups. However, I have no idea if I should use one repository for one report or for multiple reports. Say, it's nothing but git init to create a local repository for a new report but create a new repository on GitHub is much annoying. And so many repositories on GitHub are also hard to check.

I wonder if you have had the same problem and what do you guys do?

C.K.
  • 113
  • In terms of project management it would be better to have separate repositories for each document, where a document itself could consist of many version-controlled files (several chapters of a book, a bibliography file, files with code to generate images, etc.), while other projects may consist of just a single .tex file. If everything is in one repository then you can easily lose an overview of which commits belong to which document, restoring your backup will be more involved, and any git-related problem with one file will affect all your other files too. – Marijn Mar 30 '20 at 13:48
  • 1
    But it is a bit off-topic here, it would be better at https://softwareengineering.stackexchange.com. – Marijn Mar 30 '20 at 13:49
  • @Marijn Yes, you're right. Maybe there isn't the best place to talk about this question. As for this topic, what if I put every project in separate folders, and commit them in separate branches? I may not get confused this way. BTW, thanks for your commets. – C.K. Mar 30 '20 at 13:55
  • 1
    For a given instance of a repository, only one branch (or one commit in detached mode) can be checked out at a given time (i.e., be visible and usable by non-Git tools accessing the filesystem) . Do you really want this? – frougon Mar 30 '20 at 14:27
  • I'm not sure what would be the most convenient for you, that is mainly something for yourself to decide I think - each approach has some advantages. But from your description it seems like most of these reports are already finished and will not change anymore. For such a use case the difference between a single repository or multiple repositories (or multiple branches) may be smaller, because there are no commits or issues or version history etc. You could also consider not to use git at all and use a cloud backup service instead. – Marijn Mar 30 '20 at 14:34
  • @frougon Oh, yes. You're right. If I do so, I must be exhausted by switches from branch to branch. – C.K. Mar 30 '20 at 14:36
  • @Marijn Thanks! I just didn't realize the annoying switches between branches. Maybe a cloud backup service is a good idea but I have the reqirement of version control :) Again, very much thanks. – C.K. Mar 30 '20 at 14:39
  • @Marijn this one has not been closed for being off topic ;) https://tex.stackexchange.com/q/103244/177 – Alessandro Cuttin Mar 30 '20 at 17:04
  • @AlessandroCuttin https://tex.stackexchange.com/questions/54637/version-control-with-git-for-tex-latex-files-in-one-repository-or-split-to-sep has also not been closed, the current question is basically a duplicate of that one. However, I personally think all three questions are off-topic, because they are not specific for LaTeX. You could also ask "I want to backup several unrelated Python-scripts, should I use one repository or many", and get basically the same answers. – Marijn Mar 30 '20 at 17:17

1 Answers1

2

Definitely go for one document/project <-> one repository.

A simple reason behind this is that doing a partial checkout of a repository, besides being possible, is, in my opinion, more difficult to maintain on the long run.

Suppose you have

Root of LaTeX projects
 |
 |- projectA
 |- projectB
 |- projectC

If you set up the git repository for Root of LaTeX projects you will always do clone/checkout of the whole directory, even if you need only one project (again: not necessary/required, but clone/checkout are the go-to commands).

Thinking forward: suppose that at a later time you collaborate with someone on projectC. Sharing is immediate if project C has its own repository. Sharing a part of Root of LaTeX projects (or keeping it in sync with something else) may be more convoluted.

If you really want to have a versioned Root of LaTeX projects, you can use git subrepo, and you may have Root of LaTeX projects as main git repository and, inside it, you can

git subrepo clone project{A,B,C}

provided that you set up a git repository for projectX in advance. Then, you do commit as usual, and you can decide to push only on Root of LaTeX project or also the sub-repositories.

On using one branch per document: what if you have two documents opened at the same time? ;)

And, besides that, you preclude yourself the intended use of branches, for which we have a marvelous examples :)