LazyGit Tips
LazyGit is a fantastic tool that enables you to execute git flows with more speed and confidence. This resource helps you remember specific useful workflows.
- Basic Navigation
- Staging
- Switch Branches
- Discarding
- Reset to a commit
- Pull Requests
- Rebasing
- Amending Commits
- Create Revert Commit
- Patching Old Commits
- Merge Conflicts
Basic Navigation
xto open menuShift+Pto pushpto pullfto fetch- (In general) ␣ to select
- Switch between panes with ← →
Commits View
- Press enter on a commit to view file tree
- Exit with ⎋
Staging
- Select in “Files” with arrow keys
- Press ␣ to stage
- Or press
ato add all - Or press ⏎
- go through lines with ↑ ↓
- press ␣ on relevant lines
- use
vto start a range
- use
- move to diff pane with tab
- Press
don a line to unstage
- Press
- Or press
- Press
cto commit
Switch Branches
- Choose branch
- Press ␣
Switch branches with dirty tree
- Choose branch
- Press ␣
- Select autostash (with stash/pop)
- May need merge conflict resolve
Discarding
- Move to Diff view and press d on lines
- Use
din Files pane to discard the file changes Shift+D
Stashing
- All files
- Focus Files pane
- Press
s
- Individual files
- Stage the files you want to stash
- Press
Shift+S
Reset to a commit
- Select commit to go to in Commits
- Press
gto revert changes into staging area
Pull Requests
- Press
o - Opens PR in browser
Rebasing
Recap: Pull → Checkout feature branch → Make commits → Checkout master → Pull → Rebase → Push
- In Commits Pane,
- Press
e - Select commit with arrow keys
- Squash
- Press
s
- Press
- Edit → Press
e - Pick → Press
p - Fixup → Press
f - Drop → Press
d - Reorder with
Ctrl+J,Ctrl+k
- Squash
- Press m to exit
Onto origin/master
- On feature branch
- Press
fto fetch (master) - Press
rto initiate r ebase - Resolve conflict
- Press
Shift+Pto push
Amending Commits
- Stage amendments
- Select commit in Commits pane
- Press a to add staged changes
Fixup
- Stage amendments
- Select commit in Commits pane
- Shift + F
Squash fixups
- Squash fixups
- Select commit below the commit to be squash into
- Shift+S
Create Revert Commit
- Select commit in Commits pane
- Press
t
Patching Old Commits
Moving a change from one old commit to a new commit
- Select commit in Commits pane
- Press ⏎⏎
- Select line
- Press ␣ to add to a custom patch
- Press 2*⎋
- Select target commit
- Press
Ctrl+P
Merge Conflicts
- Select path to choose
- Or use
bto select both changes
- Or use
- Press ␣