This document is to highlight some common usage patterns with git, and any workflows related to version control
Useful links:
Here are some useful commands which are used in my workflow a fair bit. The alias provided with the git plugin for omz are included afterwards.
For all git aliases provided by the omz plugin, refer here.
Some general aliases:
gcam
/git commit --all --message
- commit all with messagegl
/git pull
- pull from remotegapa
/git add --patch
- patch addgp
/git push
- push to remotegrbi
/git rebase --interactive
- start interactive rebase
Some nice aliases for git logs are included by the omz git plugin. These are the ones I use most:
glo
/git log --oneline --decorate
- show log as oneline (good)glg
/git log --stat
-glgg
/git log --graph
-glog
/git log --online --decorate --graph
- oneline and graphglo
/git log --oneline --decorate
glol
- log with graph, pretty print with author and oneline.glols
to include stat too. Useglod
for a timestamp, andglods
for a date
Some git log arguments:
--stat
- show file change statistics--oneline
- display as one line--patch
- show change patch--graph
- show branch graph--date=<fmt>
- date format
Reapply commits on top of a base. Read more
git rebase -i <base>
/grbi
- interactive rebase. Use--root
as base if on root.git rebase --onto <new base> <old base> <branch name>
/gro
- change base branch
Find the commit that caused a bug using a binary search between two commits. Read more
git bisect start
/gbss
- Start bisectgit bisect good|bad <hash>
- Mark as good (gbsg
) and bad (gbsb
). Start by setting with hashes for range, and thengit bisect view
- view the current commitgit bisect reset
/gbsr
- end bisect
git-delta is used for displaying diffs using a Levenshtein edit inference algorithm
I use github far more than any other host for my git repos. So might as well use the cli where necessary.
The main command is gh
. Here's an overview of some commands.
Commands:
gh repo view
- view repo in the webgh pr view
- view pr in webgh workflow view
view workflow
Arguments:
-w
- open view command in web
lazygit is a terminal ui for git.
It can be launched in a git repo with lazygit
, or the alias lg
. From within vim, you can use the key binding <leader>gx
to open in a vim tab (remember to use <C-w>
in this tab before any git command).
Usage:
?
- help is never too far. Lazygit is powerful, this sample is too small.<C-c>
or<C-q>
- quit. Remapped fromq
h
,l
- navigate panels1
..5
- navigate panels by number[
/]
- navigate panel tabsp
- pullP
- pushR
- refreshm
- current rebase options- File Panel (Panel 2):
<CR>
- enter file to patch,<space>
to add lines,<tab>
to go between staged/unstaged panels<space>
- stage/unstage filee
- edit file in vimC
/c
- commit with editor / commit one lineA
- amend last commit
- Branches Panel (Panel 3):
<space>
- checkoutn
- new brancho
- create pull requestr
- rebase
- Log Panel (Panel 4)
<C-o>
- copy commit SHAs
- squash downf
- fixup commit
Vimdiff can be used for resolving conflicts