1
1
# Branch Workflow CLI
2
2
3
3
A cli that provides a set of ` git wf ` subcommands which simplify dealing with
4
- feature branches & GitHub pull requests. Does not require a GH API token, as
4
+ feature branches & GitHub pull requests. Does not require a GH API token, as
5
5
it just opens your browser to complete Pull Request operations.
6
6
7
- * creates named feature branches which track their intended "parent" (` start ` )
8
- * opens pull requests against the intended parent branch (` pr ` )
9
- * cleans up when done (` done ` )
10
- * aborts abandoned branches cleanly (` abort ` )
11
- * renames branches locally & on server (` rename ` )
12
- * additional optional release management commands (` cut-release ` , ` qa ` ,
13
- ` hotfix ` , ` merge-back ` )
7
+ - creates named feature branches which track their intended "parent" (` start ` )
8
+ - opens pull requests against the intended parent branch (` pr ` )
9
+ - cleans up when done (` done ` )
10
+ - aborts abandoned branches cleanly (` abort ` )
11
+ - renames branches locally & on server (` rename ` )
12
+ - additional optional release management commands (` cut-release ` , ` qa ` ,
13
+ ` hotfix ` , ` merge-back ` )
14
+
15
+ ## "master" vs "main"
16
+
17
+ Below we use the term ` main ` to refer to your mainline branch; if you have a
18
+ ` main ` branch in your local checkout, we'll assume that's the one you're using.
19
+ If not, we'll assume you're using ` master ` .
14
20
15
21
## Installation
16
22
@@ -31,9 +37,9 @@ $ git wf --help
31
37
## Commands
32
38
33
39
The ` start ` , ` pr ` , ` abort ` , ` rename ` , and ` done ` commands can be used on ** any**
34
- project that has a master branch.
40
+ project that has a master or main branch.
35
41
36
- All of the other commands will enforce the existence and use of the ` master ` ,
42
+ All of the other commands will enforce the existence and use of the ` main ` ,
37
43
` release ` , and ` hotfix ` branch naming scheme.
38
44
39
45
### ` git wf start [--fork] <name> ` - starts a new feature branch
@@ -42,18 +48,18 @@ Given you are currently on branch `<parent>`
42
48
43
49
1 . Updates the branch you currently have checked out with ` git pull `
44
50
1 . Creates a new feature branch named ` <name> ` locally with
45
- ` git checkout -b <name> `
51
+ ` git checkout -b <name> `
46
52
1 . If you specified ` --fork ` or already have a remote named ` fork ` :
47
- 1 . verifies you have a remote named ` fork `
48
- 1 . if you don't, verifies that ` <yourusername>/<reponame> ` exists on github,
49
- and if not prompts you to create it
50
- 1 . if you do have a github fork, creates the ` fork ` remote for you
51
- 1 . Pushes your feature branch to ` fork ` as a branch named
52
- ` feature/<parent>/<name> ` with
53
- ` git push -u fork <name>:feature/<parent><name> `
53
+ 1 . verifies you have a remote named ` fork `
54
+ 1 . if you don't, verifies that ` <yourusername>/<reponame> ` exists on github,
55
+ and if not prompts you to create it
56
+ 1 . if you do have a github fork, creates the ` fork ` remote for you
57
+ 1 . Pushes your feature branch to ` fork ` as a branch named
58
+ ` feature/<parent>/<name> ` with
59
+ ` git push -u fork <name>:feature/<parent><name> `
54
60
1 . If you didn't, pushes your feature branch to ` origin ` as a branch named
55
- ` <yourusername>/feature/<parent>/<name> ` with
56
- ` git push -u origin <name>:<yourusername>/feature/<parent>/<name> `
61
+ ` <yourusername>/feature/<parent>/<name> ` with
62
+ ` git push -u origin <name>:<yourusername>/feature/<parent>/<name> `
57
63
58
64
### ` git wf rename <newname> ` - renames a feature branch
59
65
@@ -62,17 +68,17 @@ branch run this command, passing a new name, it will:
62
68
63
69
1 . Fetch the latest commits from the remote
64
70
1 . Create a new remote branch named correctly, based on the fetched
65
- version of the old remote branch (no new commits from local)
71
+ version of the old remote branch (no new commits from local)
66
72
1 . Create a new local branch with the new name, based on the current
67
- local branch
73
+ local branch
68
74
1 . Make the former the upstream of the latter
69
75
1 . Delete the old local branch
70
76
1 . Delete the old remote branch
71
77
72
78
### ` git wf abort ` - aborts a feature
73
79
74
80
If you decide you don't like your new feature, you may PERMANENTLY delete it,
75
- locally and remotely, using ` git wf abort ` . This will:
81
+ locally and remotely, using ` git wf abort ` . This will:
76
82
77
83
1 . Commit any working tree changes as a commit with message "WIP"
78
84
1 . Save the SHA of whatever the final commit was
@@ -95,11 +101,11 @@ Given you are currently on a feature branch named `<name>`
95
101
1 . Deletes the feature branch with ` git branch -d <name> `
96
102
1 . Cleans up the corresponding remote branch with ` git remote prune origin `
97
103
98
- ### ` git wf cut-release [branch] ` - PRs starting a fresh release from master
104
+ ### ` git wf cut-release [branch] ` - PRs starting a fresh release from main
99
105
100
106
1 . Runs ` git wf merge-back ` (see below)
101
- 1 . Opens a PR, as per ` git wf pr ` to merge ` branch ` (default: ` master ` ) to
102
- ` release `
107
+ 1 . Opens a PR, as per ` git wf pr ` to merge ` branch ` (default: ` main ` ) to
108
+ ` release `
103
109
104
110
### ` git wf qa [branch] ` - Tags build of _ branch_
105
111
@@ -108,7 +114,7 @@ Given you are currently on a feature branch named `<name>`
108
114
1 . Switches to ` [branch] ` with ` git checkout [branch] `
109
115
1 . Updates with ` git pull --no-rebase `
110
116
1 . Tags ` HEAD ` of ` [branch] ` as ` build-YYYY.mm.dd_HH.MM.SS ` with
111
- ` git tag build-... `
117
+ ` git tag build-... `
112
118
1 . Pushes tag with ` git push origin tag build-... `
113
119
114
120
### ` git wf hotfix <build-tag> ` - Moves the hotfix branch to given tag
@@ -118,58 +124,58 @@ Given you are currently on a feature branch named `<name>`
118
124
1 . Fast-forward merges ` hotfix ` to given build tag
119
125
1 . Pushes ` hotfix ` branch
120
126
121
- ### ` git wf merge-back ` - Merges all changes back from master ← release ← hotfix
127
+ ### ` git wf merge-back ` - Merges all changes back from main ← release ← hotfix
122
128
123
129
1 . Switches to ` hotfix ` branch
124
130
1 . Pulls latest updates
125
131
1 . Merges ` hotfix ` branch to ` release ` branch - if there are conflicts, it
126
- creates a feature branch for you to clean up the results, and submit a PR.
127
- If not, pushes the merged branch.
128
- 1 . As before, but this time merging ` release ` onto ` master `
132
+ creates a feature branch for you to clean up the results, and submit a PR.
133
+ If not, pushes the merged branch.
134
+ 1 . As before, but this time merging ` release ` onto ` main `
129
135
130
136
## Example Flow
131
137
132
138
Here's a narrative sequence of events in the life of a project:
133
139
134
- * The project starts with branches ` master ` , ` release ` , and ` hotfix ` all
135
- pointing at the same place
136
- * On branch master , you ` git wf start widget-fix `
137
- * Now on branch ` widget-fix ` , you make some commits, decide it's ready to PR,
138
- and run ` git wf pr `
139
- * The PR is tested, accepted, and merged, and at some point, while on branch
140
- ` widget-fix ` , you run ` git wf done ` , which cleans it up
141
- * You start a new features, ` git wf start bad-ideea ` , make a few commits, then
142
- realize you named it wrong, so you ` git wf rename bad-idea ` - which is fine
143
- until you realize you don't want it at all, so you ` git wf abort ` and it's
144
- all gone.
145
- * A few more good features go in, and it's time to ` git wf cut-release ` -
146
- now your ` release ` branch is pointing up-to-date with ` master ` , and people
147
- can resume adding features to ` master `
148
- * It's time to QA your upcoming release, so you ` git wf qa release ` which
149
- creates a ` build-... ` tag
150
- * Your shiny new ` build-... ` tag is available for deploying
151
- however you do that, so you deploy it, QA it, and eventually release it
152
- to production.
153
- * Everything's progressing along, there's new stuff on ` master ` , maybe a
154
- new release has even been cut to ` release ` , when you realize there's
155
- a problem on production, so you run ` git wf hotfix build-... ` with the
156
- build tag that's currently on production. Your ` hotfix ` branch is now
157
- ready for fixes.
158
- * From the ` hotfix ` branch, you ` git wf start urgent-thingy ` and now you're
159
- on a feature branch off of ` hotfix ` - you make your commits to fix the
160
- bug and ` git wf pr `
161
- * People review and approve your PR, it's merged to the ` hotfix ` branch, you
162
- ` git wf done ` to cleanup
163
- * ` git wf qa hotfix ` creates a new ` build-... ` tag off of the ` hotfix ` branch,
164
- which can be QAed, then (quickly!) deployed to production
165
- * Now's a good time to run ` git wf merge-back ` , which will take those commits
166
- sitting on ` hotfix ` and merge them back onto the ` release ` branch you had
167
- in progress. This goes cleanly, so it just does it for you.
168
- * Then it goes to merge ` release ` back onto ` master ` , but uh-oh there are some
169
- conflicts by now, because someone fixed the problem a different way on
170
- ` master ` . No worries, ` git wf ` will detect that, create a feature branch
171
- to resolve the conflicts, let you clean up the merge on that branch, and
172
- then you ` git wf pr ` and it will open a PR to review the resolution.
140
+ - The project starts with branches ` main ` , ` release ` , and ` hotfix ` all
141
+ pointing at the same place
142
+ - On branch main , you ` git wf start widget-fix `
143
+ - Now on branch ` widget-fix ` , you make some commits, decide it's ready to PR,
144
+ and run ` git wf pr `
145
+ - The PR is tested, accepted, and merged, and at some point, while on branch
146
+ ` widget-fix ` , you run ` git wf done ` , which cleans it up
147
+ - You start a new features, ` git wf start bad-ideea ` , make a few commits, then
148
+ realize you named it wrong, so you ` git wf rename bad-idea ` - which is fine
149
+ until you realize you don't want it at all, so you ` git wf abort ` and it's
150
+ all gone.
151
+ - A few more good features go in, and it's time to ` git wf cut-release ` -
152
+ now your ` release ` branch is pointing up-to-date with ` main ` , and people
153
+ can resume adding features to ` main `
154
+ - It's time to QA your upcoming release, so you ` git wf qa release ` which
155
+ creates a ` build-... ` tag
156
+ - Your shiny new ` build-... ` tag is available for deploying
157
+ however you do that, so you deploy it, QA it, and eventually release it
158
+ to production.
159
+ - Everything's progressing along, there's new stuff on ` main ` , maybe a
160
+ new release has even been cut to ` release ` , when you realize there's
161
+ a problem on production, so you run ` git wf hotfix build-... ` with the
162
+ build tag that's currently on production. Your ` hotfix ` branch is now
163
+ ready for fixes.
164
+ - From the ` hotfix ` branch, you ` git wf start urgent-thingy ` and now you're
165
+ on a feature branch off of ` hotfix ` - you make your commits to fix the
166
+ bug and ` git wf pr `
167
+ - People review and approve your PR, it's merged to the ` hotfix ` branch, you
168
+ ` git wf done ` to cleanup
169
+ - ` git wf qa hotfix ` creates a new ` build-... ` tag off of the ` hotfix ` branch,
170
+ which can be QAed, then (quickly!) deployed to production
171
+ - Now's a good time to run ` git wf merge-back ` , which will take those commits
172
+ sitting on ` hotfix ` and merge them back onto the ` release ` branch you had
173
+ in progress. This goes cleanly, so it just does it for you.
174
+ - Then it goes to merge ` release ` back onto ` main ` , but uh-oh there are some
175
+ conflicts by now, because someone fixed the problem a different way on
176
+ ` main ` . No worries, ` git wf ` will detect that, create a feature branch
177
+ to resolve the conflicts, let you clean up the merge on that branch, and
178
+ then you ` git wf pr ` and it will open a PR to review the resolution.
173
179
174
180
At every stage, you don't need to stop your forward progress, forget which your
175
181
next planned release was, or anything else as you add new features and hotfix
0 commit comments