Stage modified files, stage new file or directory interactive by through fzf.
Select files/directories or modified files through fzf and stage the selected files/directories.
- Default: list all modified files and stage selected files. Support multi selection.
- `-f, --file`: list all files in current directory and stage selected files. Support multi selection. (Used for staging new files to index)
- `-d, --dir`: list all directory under current directory and stage selected directory. Support multi selection. (Used for staging new files to index)
- `-h, --help`: show the help message of `dotbare fadd` and exit.
- `-f, --file`: list all files in current directory and stage selected files. Support multi selection. (Used for staging new files to index).
- `-d, --dir`: list all directory under current directory and stage selected directory. Support multi selection. (Used for staging new files to index).
Reset/unstage file, reset HEAD back to certain commits and reset certain file back to certain
commits. Also supports reset HEAD back to certain commits either `--soft`, `--hard`, `--mixed`, as well
as reset a file back to certain commits. More information on differences [here](https://git-scm.com/docs/git-reset#Documentation/git-reset.txt-emgitresetemltmodegtltcommitgt).
Select staged files or commits through fzf and then reset(unstage) staged files or reset HEAD back to certain commits.
Also supports reset HEAD back to certain commits using either `--soft`, `--hard`, `--mixed` flags.
More information on differences between flags [here](https://git-scm.com/docs/git-reset#Documentation/git-reset.txt-emgitresetemltmodegtltcommitgt).
- Default: list all staged files and unstage the selected files. Support multi selection.
- `-c, --commit`: list all commits and then reset HEAD back to the selected commits. (Default: `--mixed`, put all changes into modified state)
- `-S, --soft`: use `--soft` flag instead of `--mixed` flag, reset HEAD to certain commit without modify working tree.
- `-h, --help`: show the help message of `dotbare freset` and exit.
- `-c, --commit`: list all commits and then reset HEAD back to the selected commits. (Default: `--mixed`, put all changes into modified state).
- `-S, --soft`: use `--soft` flag instead of `--mixed` flag, reset HEAD to certain commit without modifying working tree.
- `-H, --hard`: use `--hard` flag instead of `--mixed` flag, reset HEAD to certain commit discard all changes from the working tree.
- `-y, --yes`: acknowledge all actions that will be taken and skip confirmation.
### fcheckout
Checkout files/commit/branch interactively.
Checkout files/commit/branch interactively through fzf.
- Default: list all modified files and reset selected files back to HEAD. Support multi selection. (Discard all changes)
Note: if your file is staged, you will need to unstage first before running fcheckout to make it work.
- -a: list all tracked files and then prompt commit selection, checkout selected file in the version of selected commit.
- -b: list all branch and switch to selected branch.
- -c: list all commits and checkout selected commit.
**Note**: if your file is staged, you will need to unstage first before running fcheckout to make it work.
- `-h, --help`: show the help message of `dotbare fcheckout` and exit.
- `-s, --select`: list all tracked files and select a commit to checkout the selected files. Support multi selection.
- `-b, --branch`: list all branch and switch/checkout the selected branch.
- `-c, --commit`: list all commits and checkout selected commit.
- `-y, --yes`: acknowledge all actions that will be taken and skip confirmation.
Backup all of the tracked dotfiles to \$DOTBARE_BACKUP directory. This is used also by
`dotbare finit -u [URL]` for backing up conflicted checkout files.
Backup files to \$DOTBARE_BACKUP directory. This is particular useful when untracking files
or migrating to new machines. This is used by `dotbare finit -u [URL]` for backing up conflicted checkout files.
- Default: backup all tracked dotfiles to \$DOTBARE_BACKUP directory. (Default: use `cp`)
- -s: list all tracked files and only backup selected files. Support multi selection.
- -p PATH: specify path to files and then backup. (This is mainly used by `dotbare finit -u [URL]`)
- -m: use `mv` instead of `cp` to backup. (This is mainly used by `dotbare finit -u [URL]`)
- Default: backup all tracked files to \$DOTBARE_BACKUP directory. (Default: use `cp` command).
- `-h, --help`: show the help message of `dotbare fbackup` and exit.
- `-s, --select`: list all tracked files and only backup the selected files. Support multi selection.
- `-p PATH, --path PATH`: specify path to files to backup. (This is mainly used by `dotbare finit -u [URL]`).
- `-m, --move`: use `mv` instead of the default `cp` command to backup. (This is mainly used by `dotbare finit -u [URL]`).
### fstat
Interactively toggle stage/unstage of files. This is less used compare to `dotbare fadd`,
it might get deprecated.
Display interactive git status menu. Toggle file stage/unstage status interactively.
- `-h, --help`: show the help message of `dotbare fstat` and exit.
### finit
Initialise dotbare with a bare repository or add -u [URL] flag for migrating current
dotfiles to a new system.
Initialise dotbare with a bare repository or add -u [URL] flag for migrating existing dotfiles from
remote git repo to current system.
Note: do not use this command if you are using symlink/GNU stow.
Note: do not use this command if you are using symlink/GNU stow and want to keep your current setup.
- Default: initialise a git bare repository at \$DOTBARE_DIR
- -u URL: migrate existing bare repository from remote to current system.
- -s: if you have defined submodules in your bare repo (i.e. containes .gitmodule), add -s
- Default: init the bare repository at \$DOTBARE_DIR.
- `-h, --help`: show the help message of `dotbare finit` and exit.
- `-u URL, --url URL`: migrate existing dotfiles from remote git repo to current system.
- `-s, --submodule`: if you have defined submodules in your bare repo (i.e. containes .gitmodule), add -s
flag to clone submodules as well during migration.
- `-y, --yes`: acknowledge all actions that will be taken and skip confirmation.
### funtrack
@ -518,39 +534,54 @@ for files and then later on resume tracking changes.
**Note: This command has severe limitations.**
By default, selected files are permanently untracked starting from next commit.
It will not remove it from history. And if your other system pull down the new commit,
the untracked files on the other system will actually get removed by git. This is a limitation
with git, to overcome this, after untracking the files, run `dotbare fbackup` to backup the files.
By default, selected files are permanently untracked from git. Selected files will be
remove from index while keeping the file in your current system. However, when your other
machines pull down the changes, the untracked files will be deleted by git. This is a limitation
with git, to overcome this, after untracking the files, run `dotbare fbackup` to backup all files on
other machines before pulling down the changesto avoid any file loss.
After pulling new changes, move the deleted files from backup back to their original position.
More discussions [here](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore).
`dotbare funtrack` does come with capabilities to temporarily untrack files, which will not
actually remove the untracked files from other system. However, this is **NOT** recommended
remove the untracked files from other system. However, this is **NOT** recommended
way to untrack files, explained [here](https://www.git-scm.com/docs/git-update-index#_notes).
- Default: list all tracked files and permanently untrack the selected files. Support multi selection.
- -s: list all tracked files and temporarily untrack changes of the selected files. Support multi selection.
- -S: list all tracked files and resume tracking changes of the selected files.
- `-h, --help`: show the help message of `dotbare funtrack` and exit.
- `-t, --temp`: list all tracked files and temporarily untrack changes of the selected files. Support multi selection.
- `-r, --resume`: list all tracked files and resume tracking changes of the selected files.
- `-y, --yes`: acknowledge all actions that will be taken and skip confirmation.
### fupgrade
Update dotbare to the latest version in master. It basically just pull down changes from master,
except you don't have to cd into dotbare directory, you can run this command any where.
Update dotbare to the latest master. It will perform a `git pull --rebase --stat` and also
performing a auto-stash if needed (copied the method from OMZ). This is useful if you are not
using a plugin manager.
- `-h, --help`: show the help message of `dotbare fstat` and exit.
## Custom scripts
`dotbare` may not contains all the functionalities of your need, feel free to open up feature request. You could also
define your custom scripts under the scripts folder in `dotbare`. The `.gitignore` are configured to ignore everything except the scripts used by `dotbare` default,
so you can name your scripts any name you want. You can then track your custom scripts using `dotbare` to ensure the scripts are available in all of your machines.
Feel free to open pull request for your script, I'm happy to review and discuss for merging.
A dedicated wiki page will be setup to document API for helper functions.
## Tips and Tricks
- Most commands related to files support multi selection (default fzf setting is TAB)
- Most commands related to commits and branches doesn't support multi selection
- Most commands related to files support multi selection (default fzf setting is TAB for multi select).
- Most commands related to commits and branches doesn't support multi selection.
dotbare is unit tested on a _best effort_ due the nature of fzf which require human input.
Mock test are coming if I could make it work.
`dotbare` is unit tested using [bats](https://github.com/bats-core/bats-core). A very weird mock tests are implemented using PATH override method.
This will be improved later and documented in a dedicated README in tests folder for more readability and extensibility.
Some functions may have a lot more coverage than others, so please fire up issues if something went wrong.
dotbare uses [bats](https://github.com/bats-core/bats-core) to test individual functions.
Not all functions have 100% coverage and lots of user interaction cannot be effectively tested, please fire up issues if something went wrong.
I've added AWSCodeBuild to CI/CD just for my personal practice, if you are interested in what's happening in AWSCodeBuild
I've added AWSCodeBuild to CI/CD to build the docker image. It is mainly for my personal practice. If you are interested in what's happening in AWSCodeBuild
you could checkout my cloudformation [template](https://github.com/kazhala/AWSCloudFormationStacks/blob/master/CICD_dotbare.yaml).
## Contributing
Please help me out by pointing out things that I could improve, I've only been
scripting for a few months and are still adapting many new things every day. PR are always welcome
> A CONTRIBUTING.md is coming.
Please help me out by pointing out things that I could improve.
I've only been scripting for a few months and are still learning many new things every day. PR are always welcome
and please fire up issues if something went wrong.
Leave a star if possible :)
Leave a star :)
## Coming up
- [] Improve unit test with mocking
- [x] Improve unit test with mocking
- [x] Support submodules during migration
- [ ] Command line completion for dotbare in zsh
- [x] Command line completion for dotbare in bash
- [ ] Command line completion for git commands
- [ ] Man page
- [x] Installation method
@ -618,6 +661,7 @@ for it. I hope you find it useful and enjoy it, thanks!
- credit to [forgit](https://github.com/wfxr/forgit) for inspiration.
- credit to [fzf](https://github.com/junegunn/fzf) for fzf.
- credit to [OMZ](https://github.com/ohmyzsh/ohmyzsh) for upgrading method.
- credit to [this](https://www.atlassian.com/git/tutorials/dotfiles) post for step by step guide of setting up git bare repo.
- credit to [this](https://www.youtube.com/watch?v=tBoLDpTWVOM&t=288s) video for introducing git bare repo.