I have a large tests suite, that needs to be run before I push my changes back to the repo used by CI. Ideally I would like to use the following workflow:
If I do a git checkout, my whole working copy is changed to that branch, so I can't run my tests. Maybe I should use 2 working copies, but I would prefer a more elegant solution.
edit: typo
You can have many branches in your repository, but only one of these will be "checked out" as the working-tree so that you can work on it and make changes. git worktree adds the concept of additional working trees. This means you can have two (or more) branches checked-out at once.
You will have to make a second working copy for this; Consider that your next feature to implement may not be a new branch but instead uses an existing branch or a branch based on a different branch (anything that means you would be checking out code that reverts your last feature implementation during the test run).
You could make a script to handle all of it -- perhaps you finish development of the current feature, then run the "buildandtesteverything {featurebranchname}" script. Script will move up to the directory that contains the root of your git repository, clones the repository into a temporary folder (checking out the named branch), and then executes your tests and cleans up after itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With