git-scripts
A library of useful git commands to use when working in a feature branch workflow with submodules. The goal with all the commands are that they should work on the whole repository including submodules in every task that is executed. This to make it an easy task to use submodules.
Workflow
The workflow used is as follows
- All features branched from master
- All feature branches exist on remote
- When done with feature it is squashed to one commit (normally)
- Features are rebased onto master when done
- All submodules use the same branch names as root repository
- When feature is merged to master the branch is removed
The master branch can be another branch at some specific states of a project.
Commands
Copy the contents of the bin directory into your /usr/bin directory or runt the provided install.sh script in the bin directory - ./install.sh .
The commands included can then be used as if they were normal git commands with auto-completion using the TAB-key.
git create-feature
Creates a branch in root repository and all submodules based the branch. Checks out the new branch and pushes it to the remote. All local changes is stashed/popped before/after creation.
usage: git create-feature []
git commit-feature
Adds and commits all changes in root repository and all submodules.
If -m is used, the will be prefixed with the current branch name.
master:
usage: git commit-feature []
-c, --commit-only only commits staged changes
-m, --message
commit message
git squash-feature
Squash all commits, since branched, in current (feature) branch into one commit for root repository and submodules. Also squashes the commit messages automatically.
usage: git squash-feature [] []
usage: git squash-feature -n 3 -m "Added some..." master
-m, --message
commit message
-n, --number-of-commits
git rebase-feature
Rebase root repository and all submodules on top of latest .
usage: git rebase-feature []
-c, --continue continue rebase after a conflict (only used internally)
git push-feature
Push all changes in root repository and all submodules.
usage: git push-feature [] []
-f, --force force updates
--force-with-lease forces update if ok
git checkout-branch
Checks out in root repository and all submodules.
usage: git checkout-branch
git merge-feature
Merges in root project and all submodules into .
If is not given it defaults to current branch.
usage: git merge-feature
or: git merge-feature []
git remove-feature
Removes the in root repository and all submodules.
Both local and remote.
usage: git remove-feature [] []
-f, --force remove even if branch not merged
-l, --local-only local and remote ref removed
git clone-all
Clones a repository and all submodules.
usage: git clone-all []
git status-all
Shows the status for the root repository and all submodules.
usage: git status-all []
-s, --short show status concisely
-u, --untracked-files[=]
show untracked files, optional modes: all, normal, no. (Default: all)
git sync-branch
Checks out and pulls the latest changes for in root repository
and all submodules, using rebase.
usage: git sync-branch [] [ []]
-a, --autostash automatically stash/stash pop before and after rebase
--fetch-only performs a fetch instead of pull --rebase