Workshops always have that little extra if there is an actual codebase available that people can use as a start, of of which the exercises can build, etc. etc. Often, these GIT repo's will have exercises and example solutions on separate branches. Maintaining a repository like that is a pain in the ass, especially when you have to update a shared file on 16 different branches.
This little commandline tool, written in Golang, simplifies that a bit for you.
NOTE: There are no tests for the code (yet), so use at your own risk.
- Run
go get github.com/joostvanwollingen/workshopgitbranches
. - Run
go get -d ./...
to download the dependencies (only http://github.com/urfave/cli at the moment) - Run
go install
in the workshopgitbranches folder - Run
workshopgitbranches -v
to check if everything is setup correctly.
Or just grab a binary from the releases.
workshopgitbranches assumes you do every operation on master for now. Don't use it from other branches.
To create the branches
and shared
folders:
- Ensure you are on master.
- Run
workshopgitbranches init
.
- Put files that you need on every branch in the
shared
folder. - Put branch specific files in the
branches\<branchname>
folder. - Run
workshopgitbranches assemble
to test your build. This will create atarget
folder containing folders for each branch, merged with the shared files. Note: files that are both in the shared and branch specific folders, will be overridden with the branch specific version. - Running
workshopgitbranches build
will: delete all branches in the GIT repository that are in your branches folder, merge the shared and branch folders, create one commit with these files on each branch.
Running workshopgitbranches
against the following example directory structure would result in 5 branches, named 1_first
, 1_first_solution
, 2_second
, 3_third
, anotherbranch
. Each of the branches will contain all the files below the branch folder and the files from the shared folder. All files are included recursively.
myworkshop/ (on master branch)
├── branches
│ ├── 1_first
│ │ └── 1.txt
│ ├── 1_first_solution
│ │ └── 1.txt
│ ├── 2_second
│ │ ├── 2.txt
│ │ └── src
│ │ └── main
│ │ └── java
│ │ └── Main.java
│ ├── 3_third
│ │ └── 3.txt
│ ├── anotherbranch
│ │ └── another.txt
│ └── ignore.file
└── shared
├── shared
│ └── gotcha
├── 1.txt
├── readme.md
└── we need this too.file