# Git

- Page: https://shared.btbytes.com/p/git
- Date: 2023-02-27
- Tags: git

## Learning Git

[Why Git is hard](https://roadrunnertwice.dreamwidth.org/596185.html)
[Confusing git terminology](https://jvns.ca/blog/2023/11/01/confusing-git-terminology/); Nov 2023 by Julia Evans.

[Things I wish everyone knew about Git )](https://blog.plover.com/prog/git/tips.html) and [(Part II)](http://web.archive.org/web/20220712210951/https://blog.plover.com/2022/07/) by Mark Dominus ( plover.com )

[Inside Git](https://jvns.ca/blog/2024/01/26/inside-git/) by `jvns`.

[eficode-academy/git-katas](https://github.com/eficode-academy/git-katas), A set of exercises for deliberate Git Practice

[Oh My Git](https://ohmygit.org), learn git through playing games.

[Artisanal Handcrafted Git Repositories | drew's dev blog](https://drew.silcock.dev/blog/artisanal-git/) -- "I’m going to talk about how to handmake your git repositories without using these silly git commands. You might also learn a bit more about how git works under the hood during the process, or whatever."

[So You Think You Know Git - FOSDEM 2024 - YouTube](https://www.youtube.com/watch?v=aolI_Rz0ZqY) by Scott Chacon, now creator of [Git Butler](https://gitbutler.com)

```
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://github.com/jesseduffield/lazygit)

[https://gitless.com](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](https://spderosso.github.io/onward13.pdf) #pdf

[chshersh/zbg: ✨ Zero bullshit git](https://github.com/chshersh/zbg), porcelain for git in [ocaml](https://shared.btbytes.com/p/ocaml)


[Git man page generator](https://git-man-page-generator.lokaltog.net/); funny.

[Jujutsu/jj -  A Git-compatible DVCS that is both simple and powerful](https://github.com/martinvonz/jj)  -- It combines features from Git (data model, [speed](https://github.com/martinvonz/jj/discussions/49)), Mercurial (anonymous branching, simple CLI [free from "the index"](https://github.com/martinvonz/jj/blob/main/docs/git-comparison.md#the-index), [revsets](https://github.com/martinvonz/jj/blob/main/docs/revsets.md), powerful history-rewriting), and Pijul/Darcs ([first-class conflicts](https://github.com/martinvonz/jj/blob/main/docs/conflicts.md)), with features not found in most of them ([working-copy-as-a-commit](https://github.com/martinvonz/jj/blob/main/docs/working-copy.md), [undo functionality](https://github.com/martinvonz/jj/blob/main/docs/operation-log.md), automatic rebase, [safe replication via `rsync`, Dropbox, or distributed file system](https://github.com/martinvonz/jj/blob/main/docs/technical/concurrency.md)). [Basic jj Workflows](https://blog.chay.dev/basic-jj-workflows/)

[GitHub - jnsahaj/lumen: Beautiful git diff, Instant AI Git Commit message, Git changes summary from the CLI (no API key required)](https://github.com/jnsahaj/lumen) -- A command-line tool that uses AI to streamline your git workflow - generate commit messages, view diff and explain changes, all without requiring an API key.


## Git workflows

- [Why some of us like "interdiff" code review systems (not GitHub)](https://gist.github.com/thoughtpolice/9c45287550a56b2047c6311fbadebed2); [via lobste.rs](https://lobste.rs/s/tntsjc/)

## Hosted git

[Cloudflare Artifacts ](https://developers.cloudflare.com/artifacts/) --
