tj.git-extras/man/git-feature.md
Austin Ziegler 49650eda62
git-feature: add configurable branch separator (#1072)
* git-feature: add configurable branch separator

Closes #1069

This allows the use of a separator other than `/` for feature or other
alias branches. While a command-line option has been provided (`-s` or
`--separator`), this will most often be used via
`git-extras.feature.separator`.

* Significant update to bin/git-feature

- Changed option parsing so that `--alias` requires an argument and will
  fail with an error unless provided. Applied the same logic to
  `--separator`.

- Changed `finish` parsing to capture it as a variable flag during
  argument parsing.

  This could be extended so that if `finish` is already true, a second
  `finish` results in the word being added to the argument list.

  ```console
  $ git feature -- finish remote
  $ git feature finish finish remote
  ```

  This has not been done because it is a bit of an inconsistent handling
  for documentation purposes.

- Add handling of `--` to permit options or `finish` to be made part of
  the feature branch name.

- Since `finish` is now a variable flag, simplify the name-building
  logic to always use `concatargs "${argv[@]}"`. This means that
  `git feature finish ...` and `git feature ...` behave the same in
  terms of feature branch name building.

- Basically rewrote the man page to include better descriptions of the
  options as well as adding a GIT CONFIG section and additional EXAMPLES
  for the new features/behaviour.
2023-09-19 11:10:59 +08:00

3.7 KiB

git-feature(1) -- Create/Merge feature branch

SYNOPSIS

git-feature [-a|--alias ] [-s|--separator ] [-r|--remote [REMOTE_NAME]] [--from START_POINT] ...

git-feature [-a|--alias ] [-s|--separator ] finish [--squash] ...

DESCRIPTION

Create or merge the given feature branch. The feature branch name is made from the , the , and the joined together.

The default is feature and is /, which can be changed (see OPTIONS and GIT CONFIG for details).

The branch may be specified as multiple words which will be joined with -. If the branch name contains the word finish or is another OPTION, -- should be passed to stop OPTION parsing. See the EXAMPLES for details.

OPTIONS

  • -a , --alias :

    The branch prefix to use, or feature if not supplied.

  • -s , --separator :

    The separator to use for joining the branch prefix and the branch name, or / if not supplied.

  • -r [REMOTE_NAME], --remote [REMOTE_NAME]:

    Setup a remote tracking branch using remote_name. If remote_name is not supplied, use origin by default.

  • --from START_POINT:

    Setup a start point when the branch created. If --from is not supplied, use the current branch by default. This option will be ignored when finishing a branch.

  • finish:

    Merge and delete the feature branch.

  • --squash:

    Run a squash merge when finishing the feature branch.

  • :

    The name of the feature branch.

GIT CONFIG

You can configure the default branch prefix and separator via git config options.

  • git-extras.feature.prefix:

    $ git config --global add git-extras.feature.prefix "prefix"

  • git-extras.feature.separator:

    $ git config --global add git-extras.feature.separator "-"

EXAMPLES

  • Start a new feature:

    $ git feature dependencies
    ...
    $ (feature/dependencies) git commit -m "Some changes"

  • Finish a feature with --no-ff merge:

    $ (feature/dependencies) git checkout master
    $ git feature finish dependencies

  • Finish a feature with --squash merge:

    $ (feature/dependencies) git checkout master
    $ git feature finish --squash dependencies

  • Publish a feature upstream:

    $ git feature dependencies -r upstream

  • Use custom branch prefix:

    $ git alias features "feature -a features"
    $ git features dependencies
    $ (features/dependencies) ...
    $ (features/dependencies) git checkout master
    $ git features finish dependencies

  • Use custom branch separator:

    $ git feature -s - dependencies
    $ (feature-dependencies) ...
    $ (feature-dependencies) git checkout master
    $ git feature -s - finish dependencies

  • Use custom branch prefix and separator from git config with multiple words:

    $ git config --global --add git-extras.feature.prefix "features"
    $ git config --global --add git-extras.feature.separator "."
    $ git feature dependency tracking
    $ (features.dependency-tracking) ...
    $ (features.dependency-tracking) git checkout master
    $ git feature finish dependency tracking

  • Use a git-feature option or the finish command as part of a branch name:

    $ git feature -- finish remote
    ...
    $ (feature/finish-remote) git commit -m "Some changes" $ (feature/finish-remote) git checkout main $ git feature finish -- finish remote

AUTHOR

Written by Jesús Espino <jespinog@gmail.com>
Modified by Mark Pitman <mark.pitman@gmail.com>
Modified by Carlos Prado <carlos.prado@cpradog.com>
Modified by Austin Ziegler <halostatue@gmail.com>

REPORTING BUGS

<https://github.com/tj/git-extras/issues>

SEE ALSO

<https://github.com/tj/git-extras>, git-create-branch(1), git-delete-branch(1)