Hi I am taking a class where I expect to have 10+ assignments and 5+ projects, and instead of creating a repository for every single one, Id like to keep them in the same repository but in different folders where I can track the commits separately. Is there a clean way of doing this? Ideally they wouldn't just be on different branches as that makes tracking all of them more difficult (like in this post).
1 Answers
I'm not exactly sure what you mean by clean, but using folders as you suggested would work fine for keeping track of your work. Let's say your class is called CS413, you'd create a repository named CS413 and put each assignment or project in a folder. For example, your directory layout would be:
CS413/ (<-- This is your git repository root)
Homework1/ (<-- These are your assignment folders)
assignemnt.txt
mywork/
problem1.py
Homework2/
...
Project1/
...
You'll be able to manage all of your assignments for this one class within one project. If you want to see your history for a single assignment, you can use git log Homework1
, for example, or in github you can see the history for a single folder. You can do this all on one branch and as long as you're committing and pushing your changes regularly, you shouldn't run into any problems.
Alternatively, you could look into git-worktrees, which is a different workflow for managing multiple branches at the same time, but in github you'll have to switch branches to look at the assignment you're interested in.

- 186
- 3
-
Here's a good article about getting started with worktree's in you're interested: https://levelup.gitconnected.com/git-worktrees-the-best-git-feature-youve-never-heard-of-9cd21df67baf – jrossi Aug 28 '20 at 21:56