I use Dotbot for managing dotfiles, since Dotbot makes installing dotfiles easily. Dotbot is a tool that bootstraps your dotfiles (it's a [Dot]files [bo]o[t]strapper). It does less than you think, because version control systems do more than you think.
Dotbot is designed to be lightweight and self-contained, with no external dependencies and no installation required. Dotbot can also be a drop-in replacement for any other tool you were using to manage your dotfiles, and Dotbot is VCS-agnostic -- it doesn't make any attempt to manage your dotfiles.
If you're using Git, you can add Dotbot as a submodule details. Here I prefer install Dotbot from PyPI and call it as a command-line program.
pip3 install dotbot --user
touch install.conf.yaml
Note dotbot in this case will be installed in ~/.local/bin/
, add it to $PATH
by one-time solution:
export PATH="$HOME/.local/bin:$PATH"
or add it to .bashrc
or .zshrc
. Then you can invoke Dotbot with:
dotbot -c <path to configuration file>
vim-plug, a vim plugin manager is used
to manage plugins for vim. Plugins can be automatically installed by sourcing
~/.vimrc
and :PlugInstall
to install plugins, :PlugClean
to uninstall
plugins. Basics of vim-plug can be found here.
:Gstatus
orGit
: check the git status.s
: stage changes.u
: unstage changes.dd
orD
ordv
: show diff between last commit.:diffoff
ordq
: close diff pattern.<c-w><c-o>
: make this window the only window.X
: discard changes.P
: stage patch code.
:Git commit
: commit changescommit changes.:Git push
: push commits.:Git checkout branch
orGit switch branch
: switch branch.:Git lg
: show log graph.:Gedit
: go back the current version of code.:Gedit branch:%
: open the code in another branch:Gclog
: check the commit objects.:0Gclog
: check reversions of commits.[q
and]q
: navigation within quickfix.
:resize 20
or:vertical resize 50
: to resize the split in vim.<c-w>=
: split window equally.ma
: add local marka
.'a
: go to the marka
.:marks
: list all marks.:delm
: delete all local marks.:pc
: close preview window.:wa
: save all open buffers.:Git branch -d branch_name
: delete a local branch.:Git branch -d -r origin/branch_name
: delete a local remote branch.:Git branch -d -r origin/branch_name
: delete a local remote branch.q
and:
: search the command history in vim.
Git merge workflow in vim ref:
:Git switch target_branch
: switch to the targe branch:Git merge merge_branch
: merge the merge branch to targe branch:Gvdiffsplit!
or:G
anddv
: open the three-way diff [target, copy, merge]:diffget //2
or<leader> gh
: keep the block of code on the left (target).:diffget //3
or<leader> gl
: keep the block of code on the right (merge).:Gwrite!
: keep the wholesale code.
Compare diff workflow:
:0Gclog
: show history:[q
and]q
: move between versions:Gdiff
: opendiff
comparing the version with current one.[c
and]c
to navigate between changes.:Gedit
: return to current copy
Search and replace workflow:
<c-p>
: seach files./cat
: searchcat
in the current file.:%s/cat/dog/gc
: searchcat
and replace withdog
in the whole file.:Ag
: show grepping results of Ag across files in a floating window.<leader>ag
: show grepping results of Ag in quickfix, which is useful when seaching and replacing. Navigation by[q
or]q
Rebase feature branch onto main:
:Git switch feature_branch
:Git rebase main
- use the merge workflow in vim to solve conflicts.
Squash commits:
:Git rebase -i HEAD~3
or 1):Git lg
2) move cursor on the commit that you would like to rebase 3) typeri
to enter rebase interactive mode.- Squash the commits by highlighting with
s
.
Compare diff on two files:
- Compare two files: open one of files;
Gdiff other_files
- Compare files with another branch:
Gdiff branch_name
- Compare with files in another branch:
Gdiff branch_name:path/dir/filename
.Gdiff branch_name:%
if the same file. - Compare with files that are not tracked by git:
vimdiff file1 file2
Discard changes for unstage files:
- Discard all changes:
Git restore filename
orGit checkout -- .
,--
removes argument ambiguation - Discard changes in a certain file:
Git checkout -- filename
Revert files to previous vision:
- Revert all tracked files:
Git checkout commit_name
- Revert certain files:
Git checkout master~2 filename
Remove files from repository history:
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
--prune-empty --tag-name-filter cat -- --all
git push origin --force --all
git push origin --force --tags
Details for creating configuration files can be found here