Skip to content

Instantly share code, notes, and snippets.

@CodeMan99
Last active April 29, 2018 04:32
Show Gist options
  • Save CodeMan99/9939a27512e32e40df2132beb556bfa4 to your computer and use it in GitHub Desktop.
Save CodeMan99/9939a27512e32e40df2132beb556bfa4 to your computer and use it in GitHub Desktop.
Setup your "development" folder for more meta information.

Development Tree

Replacing a flat tree with one that has meta information baked in.

Typical Approach

When cloning projects you likely have some sort of "development" directory. That is where most, if not all, resulting directories of git clone reside. You might create a sub-directory for your employer. You might make one for your personal projects.

After a while this becomes unweildy. You start doing "deep dives" of your own filesystem.

Reasons for a Sub-Directory

Some possible reasons you have a given sub-directory (aka project) in "development".

  • You created it, a "source project".
  • You want to contribute to someone else's work, a "forked project".
  • Your employer created the project.
  • You have some reason to compile the project from source.
  • You needed to read the source. Maybe to help create a bug report. Maybe the documentation is 💩

These concerns quickly start overlapping with a traditional directory tree.

The Suggestion

Make your folder stucture mimic the web.

  • Make directories for domain names.
  • Make directories for static pathnames.
  • Use soft links for discoverability.

For me that means my "wotblitz.js" project lives at ~/dev/github.com/CodeMan99/wotblitz.js/ instead of ~/dev/wotblitz.js/. The clone of globby lives at ~/dev/github.com/sindresorhus/globby/. If I were to fork the project I would change to working directory ~/dev/github.com/CodeMan99/ and create a link called "globby".

ln -s ../sindresorhus/globby globby

Now if I list the contents of ~/dev/github.com/CodeMan99/ I see a source project named "wotblitz.js" and a fork of "globby". By reading the link path I know that globby is mainted by sindresorhus.

What about projects that live only on my computer? Simple! Your computer has a hostname, right?

mkdir -p ~/dev/localhost/new-idea/

Some Tooling

There is some very minor tooling that will aid in how useful this directory structure is. I am going to get opinioned in this section, because it is easier for me.

Order of Forking

  1. git clone the project to disk.

    cd ~/dev/github.com
    mkdir sindresorhus
    cd sindresorhus
    git clone git@github.com:sindresorhus/globby.git
    
  2. Fork the project, likely at the github.com UI.

  3. Create a soft link to the original project.

    cd ~/dev/github.com/CodeMan99
    ln -s ../sindresorhus/globby globby
    cd globby
    
  4. Create a new git remote to your fork, named fork!

    git remote add -f fork git@github.com:CodeMan99/globby.git
    

git Tips

Setup a git alias to fetch both remotes at the same time. Do it globally so you only need to do this once. Use this instead of updating with git pull.

git config --global --set alias.u "remote update"

Set git config option to default from upstream when merging. This allows you to use git merge with no arguments.

git config --global --set merge.defaulttoupstream true

Next, find a work flow to track both "origin" and "fork" the same way you would any branch HEAD. Personally, I really like tig.

tig--gulp-add

I like to use git branch -vv just as much as I use git status. In particular because I might "fast forward" my current branch, but the master branch may still be behind. This command can tell me both in one go. So I setup another alias.

git config --global --set alias.l "branch -vv"

Last, the general consencius is that you should contribute forked work on branch other than master. To help myself enforce this, I setup my master (or whatever the default is) to track with the origin remote and all other branches I track with the fork remote.

git-l

.
├── bitbucket.org
│   ├── CodeMan99
│   │   └── mako -> ../zzzeek/mako
│   └── zzzeek
│   └── mako
├── gist.github.com
│   └── CodeMan99
│   ├── node-stream-awesome
│   └── scripting
├── github.com
│   ├── atom
│   │   └── atom
│   ├── AWinterman
│   │   └── new-from
│   ├── bitinn
│   │   └── node-fetch
│   ├── bustle
│   │   └── bluestream
│   ├── caolan
│   │   └── async
│   ├── carterbs
│   │   └── lunchBot
│   ├── ChartIQ
│   │   ├── angular-2
│   │   ├── b2b
│   │   ├── ciq
│   │   ├── etoro
│   │   ├── license-server
│   │   └── react
│   ├── claudiodangelis
│   │   └── qr-filetransfer
│   ├── CodeMan99
│   │   ├── alchemists-notifier
│   │   ├── async -> ../caolan/async
│   │   ├── atom -> ../atom/atom
│   │   ├── blitzbot
│   │   ├── callpack
│   │   ├── decompress-unzip -> ../kevva/decompress-unzip
│   │   ├── discord.js -> ../discordjs/discord.js
│   │   ├── gulp-add -> ../hoho/gulp-add
│   │   ├── gulp-debug -> ../sindresorhus/gulp-debug
│   │   ├── gulp-jscrambler -> ../jscrambler/gulp-jscrambler
│   │   ├── gulp-load-plugins -> ../jackfranklin/gulp-load-plugins
│   │   ├── gulp-umd -> ../eduardolundgren/gulp-umd
│   │   ├── javascript-jscrambler -> ../jscrambler/javascript-jscrambler
│   │   ├── jscrambler -> ../jscrambler/jscrambler
│   │   ├── lunchBot -> ../carterbs/lunchBot
│   │   ├── nanorc
│   │   ├── new-from -> ../AWinterman/new-from
│   │   ├── node-promisepipe -> ../epeli/node-promisepipe
│   │   ├── opener2
│   │   ├── quick-transfer
│   │   ├── remove-accents -> ../tyxla/remove-accents
│   │   ├── RiskBattler
│   │   ├── shebang-regex -> ../sindresorhus/shebang-regex
│   │   ├── stats-ctor
│   │   ├── toflush
│   │   ├── travesty -> ../dplepage/travesty
│   │   ├── uttt
│   │   ├── wotblitz-cli.js
│   │   ├── wotblitz.js
│   │   └── wotb-scripts
│   ├── crissdev
│   │   └── gulp-remove-code
│   ├── discordjs
│   │   └── discord.js
│   ├── dplepage
│   │   └── travesty
│   ├── eduardolundgren
│   │   └── gulp-umd
│   ├── epeli
│   │   └── node-promisepipe
│   ├── expressjs
│   │   └── express
│   ├── google
│   │   └── wicked-good-xpath
│   ├── gruntjs
│   │   └── grunt
│   ├── gtanner
│   │   └── qrcode-terminal
│   ├── gulpjs
│   │   ├── vinyl
│   │   └── vinyl-fs
│   ├── hoho
│   │   └── gulp-add
│   ├── howdyai
│   │   └── botkit
│   ├── jackfranklin
│   │   └── gulp-load-plugins
│   ├── jonas
│   │   └── tig
│   ├── jscrambler
│   │   ├── gulp-jscrambler
│   │   ├── javascript-jscrambler
│   │   └── jscrambler
│   ├── kevva
│   │   ├── decompress
│   │   ├── decompress-tar
│   │   ├── decompress-tarbz2
│   │   ├── decompress-targz
│   │   ├── decompress-unzip
│   │   └── gulp-decompress
│   ├── lambtron
│   │   └── emojipacks
│   ├── louischatriot
│   │   └── nedb
│   ├── mafintosh
│   │   ├── tar-fs
│   │   └── tar-stream
│   ├── MartinKolarik
│   │   └── node-promisepipe
│   ├── maxtaco
│   │   └── tamejs
│   ├── mcollina
│   │   └── cloneable-readable
│   ├── mochajs
│   │   └── mocha
│   ├── nodejs
│   │   └── node
│   ├── nodemailer
│   │   └── nodemailer
│   ├── sindresorhus
│   │   ├── globby
│   │   ├── gulp-debug
│   │   └── shebang-regex
│   ├── TooTallNate
│   │   └── stat-mode
│   ├── tyxla
│   │   └── remove-accents
│   ├── VFK
│   │   └── gulp-html-replace
│   ├── workshopper
│   │   ├── learnyounode
│   │   └── stream-adventure
│   └── zkat
│   └── npx
├── git.kernel.org
│   └── git
│   └── git
├── git.savannah.gnu.org
│   └── nano
└── localhost
├── ChartIQ
│   ├── build
│   ├── chartiq-serve
│   ├── database-query
│   ├── jscrambler
│   ├── locking
│   ├── paver
│   ├── rawpack
│   └── ssqueue
└── CodeMan99
├── Alchemists
├── bgg-to-dt
├── codefights
├── codewars
├── contest17
├── d6
├── formula-d
├── gulp-concat-2
├── igp
├── jsonp
├── prompack
├── proofs
├── rc-tools
├── rm-kernels
├── score-tickets
├── score-ttr
└── snippets
185 directories
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 Alchemists
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 alchemists-notifier
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 angular-2
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 async
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 atom
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 b2b
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 bgg-to-dt
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 blitzbot
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 bluestream
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 botkit
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 build
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 callpack
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 chartiq-serve
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 ciq
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 cloneable-readable
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 codefights
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 codewars
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 contest17
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 d6
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 database-query
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 decompress
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 decompress-tar
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 decompress-tarbz2
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 decompress-targz
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 decompress-unzip
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 discord.js
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 emojipacks
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 etoro
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 express
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 formula-d
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 git
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 globby
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 grunt
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-add
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-concat-2
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-debug
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-decompress
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-html-replace
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-jscrambler
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-load-plugins
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-remove-code
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 gulp-umd
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 igp
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 javascript-jscrambler
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 jscrambler
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 jsonp
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 learnyounode
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 license-server
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 locking
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 lunchBot
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 mako
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 mocha
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 nano
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 nanorc
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 nedb
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 new-from
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 node
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 node-fetch
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 nodemailer
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 node-promisepipe
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 node-stream-awesome
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 npx
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 opener2
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 paver
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 prompack
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 proofs
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 qrcode-terminal
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 qr-filetransfer
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 quick-transfer
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 rawpack
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 rc-tools
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 react
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 remove-accents
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 RiskBattler
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 rm-kernels
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 score-tickets
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 score-ttr
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 scripting
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 shebang-regex
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 snippets
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 ssqueue
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 stat-mode
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 stats-ctor
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 stream-adventure
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 tamejs
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 tar-fs
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 tar-stream
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 tig
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 toflush
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 travesty
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 uttt
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 vinyl
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 vinyl-fs
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 wicked-good-xpath
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 wotblitz-cli.js
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 wotblitz.js
drwxrwxr-x 4 code_m code_m 4.0K Feb 26 10:43 wotb-scripts
Alchemists alchemists-notifier angular-2 async atom b2b bgg-to-dt blitzbot
bluestream botkit build callpack chartiq-serve ciq cloneable-readable
codefights codewars contest17 d6 database-query decompress decompress-tar
decompress-tarbz2 decompress-targz decompress-unzip discord.js emojipacks etoro
express formula-d git globby grunt gulp-add gulp-concat-2 gulp-debug
gulp-decompress gulp-html-replace gulp-jscrambler gulp-load-plugins
gulp-remove-code gulp-umd igp javascript-jscrambler jscrambler jsonp
learnyounode license-server locking lunchBot mako mocha nano nanorc nedb
new-from node node-fetch nodemailer node-promisepipe node-stream-awesome npx
opener2 paver prompack proofs qrcode-terminal qr-filetransfer quick-transfer
rawpack rc-tools react remove-accents RiskBattler rm-kernels score-tickets
score-ttr scripting shebang-regex snippets ssqueue stat-mode stats-ctor
stream-adventure tamejs tar-fs tar-stream tig toflush travesty uttt vinyl
vinyl-fs wicked-good-xpath wotblitz-cli.js wotblitz.js wotb-scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment