Git

Distributed Version Control System

Created: by Pradeep Gowda Updated: Jan 27, 2024 Tagged: git

Learning Git

Why Git is hard Confusing git terminology; Nov 2023 by Julia Evans.

Things I wish everyone knew about Git ) and (Part II) by Mark Dominus ( plover.com )

Inside Git by jvns.

So You Think You Know Git - FOSDEM 2024 - YouTube by Scott Chacon, now creator of Git Butler

USEFUL CONFIG STUFF

$ git config --global alias.staash 'stash --all'
$ git clean

https://gist.gihub.com/schacon

$ git config --global alias.bb !better-branch.sh

Conditional Configs
[includeif "gitdir:~/projects/work/"]
    path = ~/projects/work/.gitconfig
[includeif "gitdir:~/projects/oss/"]
    path = ~/projects/oss/.gitconfig

OLDIES BUT GOODIES

$ git blame -L
git blame a portion of the file

$ git log -L 15,26:path/to/file
works the same way with git log

$ git blame -w
ignore whitespace

$ git blame -w -C
.. and detect lines or copies in the same commit

$ git blame -w -C -C
.. or the commit that created the file

$ git blame -w -C -C -C
.. or any commit at all

$ git log -S files_watcher -p
the pickaxe

$ git reflog

$ git diff --word-diff

$ git config --global rerere.enabled true
REuse REcorded REsolution

NEW STUFF

$ git branch --column

$ git config --global column.ui auto
$ git config --global branch.sort -committerdate

$ git push --force-with-lease
This one is better than using --force by default

signing commits with ssh
$ git config gpg.format ssh

$ git push --signed
github and gitlab do not support it.

$ git maintenance

gc(disabled),
commit-graph and prefetch (hourly),
loose-objects incremental-repack (daily)
pack-refs (none)

BIG REPO STUFF

Half a million files in working directory

windows rpeo - 300gb, 3.5 million files
linux kernel - 4.5gb in comparison

prefetching
$ git for-each-ref | grep prefe

commit-graph
$ git config --global fetch.writeCommitGraph true

filesystem monitor
$ git config core.untrackedcache true
$ git config core.fsmonitor true

partial cloning
$ git clone --filter=blob:none
$ git clone --filter=tree:0

GITHUB STUFF

auto merge

merge queue

$ git ls-remote

"all mypull requests are actual refs"

$ git config remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*'

$ git fetch


GITBUTLER

virtual branches

Tools

jesseduffield/lazygit: simple terminal UI for git commands

https://gitless.com – A Git-compatible VCS that does away with the staging area (and stashes), and instead has separate working dirs for every branch (branch = automatically stashed). They have a detailed analysis of Git that explains their design: What’s wrong with Git? A conceptual design analysis #pdf

chshersh/zbg: ✨ Zero bullshit git, porcelain for git in ocaml

Git man page generator; funny.

Jujutsu/jj - A Git-compatible DVCS that is both simple and powerful  It combines features from Git (data model, speed), Mercurial (anonymous branching, simple CLI free from “the index”revsets, powerful history-rewriting), and Pijul/Darcs (first-class conflicts), with features not found in most of them (working-copy-as-a-commitundo functionality, automatic rebase, safe replication via rsync, Dropbox, or distributed file system).