项目作者: claudiobizzotto

项目描述 :
Git subtree aliases (shortcuts)
高级语言:
项目地址: git://github.com/claudiobizzotto/gitane.git
创建时间: 2017-01-15T16:56:51Z
项目社区:https://github.com/claudiobizzotto/gitane

开源协议:MIT License

下载


Gitane

Git subtree aliases. Use these shortcuts when dealing with git subtree and avoid repetitive strain injuries :no_mouth:

Installation

You’ll probably want to put these shortcuts in your user’s global configuration file, typically $HOME/.gitconfig, but you can alternatively restrict them to the configuration file under a specific repository (./git/config).

Just place the following three aliases in the chosen configuration file under the alias section:

  1. [alias]
  2. st-add = "!f() { \
  3. DEFAULT_BRANCH=master; \
  4. DEFAULT_DIR=$(basename $1 | cut -d. -f1); \
  5. git subtree add --prefix $DEFAULT_DIR $1 ${2:-$DEFAULT_BRANCH} --squash; \
  6. }; f"
  7. st-pull = "!f() { \
  8. DEFAULT_BRANCH=master; \
  9. DEFAULT_DIR=$(basename $1 | cut -d. -f1); \
  10. git subtree pull --prefix $DEFAULT_DIR $1 ${2:-$DEFAULT_BRANCH} --squash; \
  11. }; f"
  12. st-push = "!f() { \
  13. DEFAULT_BRANCH=master; \
  14. DEFAULT_DIR=$(basename $1 | cut -d. -f1); \
  15. git subtree push --prefix $DEFAULT_DIR $1 ${2:-$DEFAULT_BRANCH}; \
  16. }; f"

You can change the default branch from master to anything you wish. You can also remove the --squash option if you want to import the entire history from the subproject rather than just a single commit.

Usage

You start by adding a subproject to your main project:

  1. $ git st-add <remote repository> <optional branch name>

Example:

  1. $ git st-add git@github.com:my-org/my-repo.git development

This will include git@github.com:my-org/my-repo.git (development branch) as a subproject in the ./my-repo directory.

The remaining commands (st-pull and st-push) are self-explanatory and follow the same syntax.