When you’re about to create a new source file, always check to verify you’re doing it within some repo. If it’s for a brand new thing, consider creating a new repo.
Why? So it eventually gets saved to the cloud. Some folks use SVN,
perforce, and others for versioning, but on modern projects the right
answer will almost always be “git”. So it’s enough to verify that
git status
shows your new file, perhaps as untracked. You
don’t
have
to
git add
it, but usually it wouldn’t
hurt, you can always
git rm
it later.
Some scripts truly are throw away one-offs. That’s fine. Put it in a repo anyway, where it will appear as a line of status output until you add or rm it. That line of output is a friendly reminder.
Oh, let me count the ways! Here are just a few.
git diff
current against what
was recently working.
git push
, and then you’re safe from
rm -rf .
, laptop stolen from car, and other mishaps.
git blame
to reveal state-of-mind and timestamp
of last edit .
That last item is multi-faceted, and if code doesn’t start out in a repo it might not even occur to you to take advantage of the PR process.
I have seen people do remarkable things with source, including
People do such things in good faith. Maybe their professor or colleagues never requested source in a particular manner. It’s just a matter of folks approaching same situation from different academic cultures where there are different norms.
I have also seen people create branches named after Partner-A,
Partner-B …, with the intent that they exist forever and are never
merged down. Some branches are immortal, like
main
and
develop
. Others should typically last for a sprint or two
and then go through PR, merge, delete. Use
mkdir
to carve
out a bit of namespace if there’s partner specific details that need to
be buried somewhere. That allows the files to still be available after
checking out various branches.
Don’t burden your colleagues with a branch that slowly bit rots and will never be merged. Before long it will show lint issues, failed tests, dangling references to renamed methods and so on. Best to halt the pain by deleting it.
Copyright 2022 John Hanley. MIT licensed.