[Tutor] OT: How best to use Git for multi-directory projects?

Martin A. Brown martin at linux-ip.net
Wed Dec 30 00:32:32 EST 2015


Hello there boB,

Hey, wait a second!  What time zone are you in?  You can't have 2016 
resolutions already.  Not even the New Zealanders are there yet!

>I have two situations that I wish to use Git for:  1) Multi-directory
>Python projects and 2) learning Python from various books which
>inevitably have suggested exercises to program solutions for.
>
>For (1) I might have multiple projects going simultaneously.  Say
>something like:

[snip]

>My thoughts are that each project should have its own .git file.

N.B. this is not a Python question, but ... do you mean .git 
directory?

>If this is correct, then I further think that there should be a 
>single .git file to track everything in each project folder at its 
>top level and use git add . at the project folder level to add 
>anything that has been added anywhere in any subfolder of the 
>project folder.  Am I thinking correctly in this?

>For (2) I first want to state publicly:
>
>New Year's Resolution:
>
>I WILL study--in parallel--the following three books from cover to
>cover, doing ALL non-trivial exercises:
>    "Think Python, 2nd Edition" by Allen Downey
>    "Introduction to Computation and Programming Using Python, Revised and Expanded Edition" by John V. Guttag
>    "Python Crash Course" by Eric Matthes

(Side note:  I do not know any of these three books.)

Reading cover to cover is one way to go about it.  I think that it 
helps to balance such thorough and complete study of books with the 
direct experience of writing software.

Also, I might suggest one other reference and technique--it is more 
a generic strategy for continuous learning, here applied to 
increasing your Python proficiency.

Pick one standard library module per week (or day) and read the 
whole page of documentation.  Pick a module that is relevant to some 
problem you are solving and study each function of the module.  

Alternate between the common ones (in my world:  sys, os, time, 
math, string, re, random, csv, httplib, urllib) and some others 
(hashlib, difflib, sched, bz2, itertools, multiprocessing).  Of 
course, start by tailoring your module choice to your tasks.

>But to the questions.  This seems essentially parallel to (1) in 
>regards to using Git.  I want to track all of the programming work 
>I do for these 3 books.  I anticipate a directory structure similar 
>to:
>
>StudyBooks/
>    Book1/
>        Ch1/
>            example1.py
>            example2.py
>            exercise1.py
>            etc
>        Ch2/
>        etc
>
>    Book2/
>etc.
>
>Since I will be studying these 3 books in parallel, would it make
>sense to track everything with a single .git file at the level of
>StudyBooks directory?

I'm accustomed to keeping a single git repository for each distinct 
project or program I'm working on.  In the context of Python, I 
create a separate git repository for each distribution that I may 
release.  (So, if I am going to write a new "setup.py", then it is 
time for a new git repository.)

To apply this approach to your case, I would make a different git 
repository for each StudyBook.

There are different strategies depending on what you are doing with 
the software and the environment in which you are working.

Good luck and have fun with Python in 2016, since you have arrived 
there before the rest of us,

-Martin

P.S. Two questions:  should I buy some some YHOO stock and should I
   sell my Euros?

-- 
Martin A. Brown
http://linux-ip.net/


More information about the Tutor mailing list