initial commit
[git-wtree.git] / README.md
1 # git-wtree
2
3 Several naive `(ba)sh`-shortcuts for `git worktree` subcommand.
4
5 ## Overview
6
7 Creation of `git` worktrees and switching between them is quite verbose thing to do for my regular use-cases. `git-wtree` is intended to simplify this routine.
8 This one is a simple shell script supposed to be sourced inside of a shell. It was intentionally developed in a shell-agnostic way (no bashishm's are used) but tested with `bash` only and `git` 2.18.0.
9
10 ## Installation
11
12 Inside of `~/.bashrc`:
13
14     # The comment for the line below could be removed to establish short aliases for provided commands
15     # GIT_WTREE_ALIAS_ENABLED=true
16
17     . git-wtree/git-wtree.sh
18
19 ## Usage
20
21 Inside of `git` repository where worktrees are supposed to be intensively used:
22
23     git config --local worktree.root <ROOT_DIR>
24
25 where `<ROOT_DIR>` is a directory where all worktrees are created and removed from.
26
27 ### Create worktree
28
29     git_wtree_cmd_new --name <BRANCH_NAME> --dir <DIR>
30     
31     # alias:
32     git.wtree:ls --name <BRANCH_NAME> --dir <DIR>
33
34 where:
35
36 - `<BRANCH_NAME>` is name of the branch to be created;
37 - `<DIR>` is name of directory inside of `<ROOT_DIR>`
38
39 vs native `git worktree add -b <BRANCH_NAME> <ROOT_DIR>/<DIR>`.
40
41 ### Delete worktree
42
43     ```bash
44     git_wtree_cmd_drop --name <BRANCH_NAME>
45     # alias:
46     git.wtree:drop --name <BRANCH_NAME>
47     ```
48
49 where `<BRANCH_NAME>` is a name of the branch to be deleted.
50
51 vs native `git worktreee remove <FULL_PATH_TO_DIR_OF_BRANCH_NAME>`
52
53 ### List branches inside worktrees
54
55     git_wtree_cmd_ls
56     # alias:
57     git.wtree:ls
58
59 vs native `git worktree list` and futher grepping for a branch name.
60
61 ### Switch to a worktree dir
62
63     git_wtree_cmd_tool_cd <BRANCH_NAME>
64     # alias:
65     git.wtree:cd <BRANCH_NAME>
66
67     git_wtree_cmd_tool_pushd <BRANCH_NAME>
68     # alias:
69     git.wtree:pushd <BRANCH_NAME>
70
71 vs native `git worktree list`, grepping and furhter cd/pushd execution.
72
73 # License
74
75 MIT
76