This feature provides a set of utilities for working with Git repositories.
"features": {
"ghcr.io/tomgrv/devcontainer-features/gitutils:11": {}
}npx tomgrv/devcontainer-features -- add gitutils
# or, without node/npm:
curl -fsSL https://raw.githubusercontent.com/tomgrv/devcontainer-features/develop/setup.sh | sh -s -- add gitutilsnpm install --save-dev @tomgrv/devcontainer-features-gitutilsInstalls a collection of Git utilities. Installs the git-flow extension and sets up Git configuration to use it. Adds shortcuts to the git command for easier use of git-flow commands.
The utilities themselves live in tomgrv/scripts
(one source of truth, shared with every other tomgrv/perspikapps repo)
and are pulled in via zz-use at install time — this feature owns the
alias/config wiring and the git-flow install/configure lifecycle, not the
script implementations.
Additionally, the feature installs the git-flow extension and sets up the Git configuration to use it.
git-flow (the gitflow-avh package) is installed as an OS package by install-gitflow.sh, which runs once when the feature is installed — primarily satisfied by the common-utils feature dependency already, with a package-manager-detecting fallback if it's still missing.
feature-configure gitutils (run automatically from postCreateCommand, and re-runnable at any time from the repository root) runs configure-gitflow.sh, which non-interactively runs git flow init -d -f with the following branch/prefix scheme:
| Prompt | Value |
|---|---|
| Branch for production releases | main |
| Branch for "next release" integration | develop |
| Feature branches prefix | feature/ |
| Bugfix branches prefix | bugfix/ |
| Release branches prefix | release/ |
| Hotfix branches prefix | hotfix/ |
| Support branches prefix | support/ |
| Version tag prefix | v |
| Hooks and filters directory | .git/hooks (default) |
Each value can be overridden by exporting the matching environment variable before configure-gitflow.sh runs: GITFLOW_MASTER_BRANCH, GITFLOW_DEVELOP_BRANCH, GITFLOW_FEATURE_PREFIX, GITFLOW_BUGFIX_PREFIX, GITFLOW_RELEASE_PREFIX, GITFLOW_HOTFIX_PREFIX, GITFLOW_SUPPORT_PREFIX, GITFLOW_VERSIONTAG_PREFIX.
If main/develop don't exist locally but a matching origin/main/origin/develop does (e.g. a fresh clone), configure-gitflow.sh checks that branch out rather than creating an orphan branch, so existing history is preserved.
feature-configure gitutils also runs configure-knownhosts.sh, which seeds ~/.ssh/known_hosts with github.com's key via ssh-keyscan. openssh-client (providing ssh-keyscan) is not a hard dependency of this feature — if it isn't installed, the script exits cleanly with no error and no known_hosts changes.
Shortcuts are also added to the git command to make it easier to use the git-flow commands:
git betais a shortcut forgit flow release startgit hfixis a shortcut forgit flow hotfix startgit prodis a shortcut forgit flow release finishandgit flow hotfix finish
These shortcuts work in conjunction with the gitversion utility to automatically update the version number of the application.
.gitattributes marks *.json and *.yaml/*.yml with merge=json/merge=yaml,
but a driver name is only meaningful once registered in Git config. The
configure-mergedrivers.sh lifecycle script registers both, at repo scope:
git config merge.json.driver 'json-merge %A %B'
git config merge.yaml.driver 'yaml-merge %A %B'
With these registered, git merge/git rebase/git cherry-pick resolve
conflicts on JSON/YAML files by recursively merging objects and
deduping/unioning arrays (via json-merge/yaml-merge)
instead of falling back to a line-based 3-way merge.
Consumer repos get one deployed workflow under .github/workflows/:
release-prod.yml— the production release entry point, viatomgrv/actions/release-promote, which drives the samegit-release-beta/git-release-prodflow (tomgrv/scripts) exposed above as thegit beta/git prodaliases.
Agent guidance for downstream repos using this feature:
- Always open pull requests with base
develop, nevermain. - Never push or open a PR directly against
main— production releases go out only through therelease-prodworkflow. - Trigger
release-prodwith thegh-prodcommand (a thingh workflow run release-prod.ymlwrapper) or viaworkflow_dispatchin the GitHub UI.
The feature includes the following interactive utilities:
git align- Align the current branch with its remote counterpart.git degit <repository> [directory]- Download and extract a repository from GitHub, GitLab, or Bitbucket.git fix date [options] [<commit>]- Fix commit dates and times in git history. Options include rescheduling commits on specific days of week outside certain time ranges.git fix blanks [-d]- Discard tracked text-file changes when differences are only whitespace, blanks, and quote/slash swaps.git fix message -m <message> [--force|<commit>]- Rewrite the commit message of a specific commit.git fix orphans [-p] [-x <prefix>] [<remote>]- List (or, with-p, rename on the remote) the branches that do not follow the gitflow config and have no pull request, prefixing them withorphan/. Does nothing when no gitflow config is defined. Themanage-orphan-branchesworkflow runs it weekly.git fix prune [<remote>]- Prune remote-tracking references that no longer exist on the remote (defaults to all remotes). Runs automatically onpostStartCommand.git fix secrets -g <glob> -s <secret> [-r <replace>] [-f] [-p] [-d] [-m] [-t] [<commit>]- Redact a secret from files matching a glob pattern (and optionally commit messages and tag annotations) across all git history, replacing it with****(or-r <replace>).git fix up [--force|<commit>]- Amend the specified commit with current changes and rebase (alias:git fu).git forall <command>- Execute a command for all files in the repository.git getcommit [--force|<commit>]- Get the commit to fixup. Pass0as<commit>to resolve to the very first commit in history.git integrate- Integrate modifications from the remote repository.git release-beta- Start a new release branch using Git Flow.git release-hotfix- Start a new hotfix branch using Git Flow.git release-prod- Finish a release or hotfix branch using Git Flow.gh-prod- Trigger therelease-prodGitHub Actions workflow (gh workflow run release-prod.yml).git fix rights- Set permissions for files and directories according to best practices.git unset <prefix> [--local|--global|--system]- Unset all Git config keys starting with the given prefix.
The following aliases are provided to enhance your Git workflow:
git amend- Amend the last commit with the current changes.git beta- Start a new release branch using Git Flow.git cleanup- Stash all changes, clean the working directory, and apply the stash.git co <message>- Commit with the provided message.git conflict- List files with merge conflicts.git continue- Continue the rebase process after resolving conflicts.git fixable- List commits that can be fixed up.git forceable- List commits that can be force-pushed.git go <message>- Commit all changes with the provided message.git hfix- Start a new hotfix branch using Git Flow.git histo- Show the commit history from the last merge.git ignore <file>- Add the specified file to.gitignoreand remove it from the index.git initFrom <repo> <dir>- Clone a repository and set up branches.git isChanged <file>- Check if the specified file has changed.git isDirty <file>- Check if the specified file has uncommitted changes.git isFixup- Check if the last commit is a fixup commit.git isRebase- Check if a rebase is in progress.git pn- Push without running pre-push hooks.git prod- Finish a release or hotfix branch using Git Flow.git renameTag <old> <new>- Rename a tag.git stack- Amend the last commit without changing the commit message.git sync- Fetch and merge changes from the upstream branch.git undo- Undo the last commit, keeping the changes in the working directory.
The feature also includes the following VS Code customizations:
-
Extensions:
donjayamanne.githistorytomblind.scm-buttons-vscodemhutchie.git-grapharturock.gitstashgithub.copilotgithub.copilot-chatgithub.vscode-github-actionsgitHub.vscode-pull-request-githubgithub.codespaceswaderyan.gitblame
-
Settings:
explorer.excludeGitIgnore:truegit.autorefresh:true
git fix datereschedules commit dates and times in history (e.g. weekday commits moved outside working hours), keeping their order — seegit-fix-date.git fix secretsredacts a literal secret from files, commit messages and tag messages across history — seegit-fix-secrets.
Both rewrite history: use -f carefully, it allows overwriting pushed history.
If you have a feature that you would like to add to this repository, please open an issue or submit a pull request.