|
2 | 2 |
|
3 | 3 | # gitspaces - A git development workspace manager |
4 | 4 |
|
5 | | -> NOTE: I am calling all things "scripts". They are actually no scripts at all that are called from the cmdline. They are all bash aliases and functions, but to have one word, I call everything scripts. |
6 | | -
|
7 | | -## Upcoming Work |
8 | | - |
9 | | -- [ ] Convert bash scripts into either python or golang with a light shell wrapper (to support changing directories) |
10 | | - |
11 | | -## Overview |
12 | | - |
13 | | -GitSpaces is a set of bash scripts for managing git-based development workspaces. The main features are |
14 | | - |
15 | | -1. Space management |
16 | | - * Multiple spaces |
17 | | - * Multiple repositories per space |
18 | | - * Space hibernation |
19 | | - * Space renaming |
20 | | - * Per user, space configuration overrides |
21 | | -2. Cross-repository branch management |
22 | | - * Common Development aids (multi-repo branch sets for ensuring on Development/Production/... branches) |
23 | | - * Common (and uncommon) git alias |
24 | | - * Directory change aliases (to each repository) |
25 | | - * Visual Studio Code per workspace |
26 | | - |
27 | | -## Background |
28 | | - |
29 | | -The general idea is that for any given project you might be working on a feature here, a hotfix there, another feature there, |
30 | | -and a bugfix somewhere else. You may handle all of these "concurrent" activities by forcing yourself to commit on your branch, |
31 | | -change branches, or stash stuff. I've found that to be a lot of overhead especially if you are coordinating this across multiple |
32 | | -repositories in a project. |
33 | | - |
34 | | -For those of you with a, ahem, ClearCase background, you're familiar with the concept of ClearCase Views. Essentially it's an |
35 | | -isolated workspace that has all of your project code where you can work on ONE THING. If you are asked to fix a bug or |
36 | | -something else concurrently, you just create a new view (they're cheap) and work there. Unfortunately, git has no concept |
37 | | -like this. Clones are expensive, committing just to context switch is a pain and messes up your commit history to boot. |
38 | | - |
39 | | -Gitspaces are essentially a lightweight implementation of ClearCase Views for git projects. |
40 | | - |
41 | | -## Command overview |
42 | | - |
43 | | -Once gitspaces scripts are available in your environment, all gitspaces commands are prefixed with `gs`. e.g. |
44 | | - |
45 | | -Command | Description |
46 | | -------------|------------------------ |
47 | | -`gs switch` | Switch to a different top-level gitspace project. |
48 | | -`gs ls` | List repository information (e.g., what branch they are on) |
49 | | -`gs mv` | Rename a current gitspace |
50 | | -`gs sleep` | Archive a gitspace (not using it currently - renames to _.zzz-# and hides from lists) |
51 | | -`gs cd` | cd around a gitspaces project. Switch gitspace, repos, folder |
52 | | -`gs cd -` | Switch to a different gitspace (allows you wake one up you put to sleep to use fresh) |
53 | | -`gs co` | Choose from a list of 'BranchSet's (in gsconfig.ini) and will git pull each repos to it's specified branch |
54 | | -`gs code` | Launches Visual Studio Code with .code-workspace file updated with proper paths for debugging |
55 | | -`gs init` | _TODO_: Creates project gitspaces.ini, spaces-dir, and first gs space folder (firstspace) |
56 | | -`gs cp` | _TODO_: Copies an existing gitspace folder to create another (and puts it to sleep) |
57 | | - |
58 | | - |
59 | | -## Quick Setup |
60 | | - |
61 | | -1. Download/Clone gitspaces repo and add it to your .bashrc file |
62 | | - |
63 | | - ``` |
64 | | - cd ~ |
65 | | - git clone <repo-path> .gitspaces |
66 | | - echo ". ~/.gitspaces/gitspaces.sh" >> ~/.bashrc |
67 | | - cp ~/.gitspaces/userfiles/.gitspacesrc.sh ~/ |
68 | | - perl -pi -e "s/^#alias/alias/ ~/.gitspacesrc.sh # aliases gs=gitspaces, cds='gs cd' |
69 | | - . ~/.bashrc |
70 | | - ``` |
71 | | - |
72 | | -2. Create a code project folder (will house projectA's gitspaces) |
73 | | - |
74 | | - ``` |
75 | | - mkdir -p ~/code/projectA |
76 | | - ``` |
77 | | - |
78 | | -3. Setup a GitSpaces project folder |
79 | | - > Future: this is what 'gs init' will do |
80 | | - ``` |
81 | | - cd ~/code/projectA |
82 | | - cp ~/.gitspaces/userfiles/gitspaces.ini . # See file comments for details |
83 | | - mkdir $GITSPACES_SPACESDIR # defaults to '_' # Where all of your project spaces will live |
84 | | - mkdir -p $GITSPACES_SPACESDIR/firstspace # First project space, you can rename it later |
85 | | - cd $GITSPACES_SPACESDIR/firstspace |
86 | | -
|
87 | | - # A GitSpaces project folder has the following structure: |
88 | | - ~/code/projectA/ |
89 | | - |- gitspaces.ini |
90 | | - |- _/ |
91 | | - +- space-1/ |
92 | | - +- projectA-repo-1 |
93 | | - ... |
94 | | - +- projectA-repo-N |
95 | | - ... |
96 | | - +- space-N/ |
97 | | - +- projectA-repo-1 |
98 | | - ... |
99 | | - +- projectA-repo-N |
100 | | - ``` |
101 | | - |
102 | | -4. Clone all of your repositories into the \_.first gitspace folder |
103 | | - |
104 | | - ``` |
105 | | - cd ~/code/projectA/_/firstspace |
106 | | - git clone <projectA-repo1> |
107 | | - ... |
108 | | - git clone <projectA-repoN> |
109 | | - ``` |
110 | | - |
111 | | -5. Create additional GitSpaces for projectA |
112 | | - > Simply 'cp -R firstspace secondspace' (way faster usually than re-cloning) |
113 | | - > Note the copy operation is way quicker if you clean your firstspace repos' (git clean -dx -f) |
114 | | - ``` |
115 | | - cd ~/code/projectA |
116 | | - cp -R firstspace secondspace |
117 | | - ... |
118 | | - cp -R firstspace nthspace |
119 | | - ``` |
120 | | - |
121 | | - You can add a new gitspace folder anytime you want when you need more. I've generally found that 5 are sufficient. |
122 | | - |
123 | | -6. Add your new GitSpaces project to GITSPACES_PROJDIRS in ~/.gitspacesrc.sh and resource |
124 | | - |
125 | | -7. Start using GitSpaces |
126 | | - |
127 | | -8. Optional: Include ~/.gitspaces/userfiles/gitconfig |
128 | | - |
129 | | - My common git aliases are in the userfiles folder. Just add the following to your ~/.gitconfig |
130 | | - |
131 | | - ``` |
132 | | - [include] |
133 | | - path = ~/.gitspaces/userfiles/gitconfig |
134 | | - ``` |
| 5 | +TODO update docs for v2 (golang, simplified, edition) |
0 commit comments