How core Git developers configure Git
blog.gitbutler.com
blog.gitbutler.com
zdiff3 is also NOT some kind of generic improvement over diff3, like swapping diff algorithms is sorta a generic improvement. It behaves very differently; if you have
[original]
this is a line
[left branch]
This is a line.
This is a second line.
[right branch]
This is a line.
This is another line.
then diff3 shows <<<<<<<
This is a line.
This is a second line.
|||||||
this is a line
=======
This is a line.
This is another line.
>>>>>>>
while zdiff3 modifies this in a very matter-of-personal-taste way to: This is a line.
<<<<<<<
This is a second line.
|||||||
this is a line
=======
This is another line.
>>>>>>>
This is incredibly bizarre to my eye, but some prefer how it's already "partially resolved" for them. But it's hardly something to swap in thoughtlessly for the other!zdiff3 is described here: < https://git-scm.com/docs/git-merge#_how_conflicts_are_presen...>. The example in there makes zdiff3 look quite confusing, since it makes it look as though a line was deleted on both sides. For a while, I thought including the identical line in the base it must be a typo, but apparently that's how it's supposed to work.
See also https://lore.kernel.org/git/CAO_smVg=1gFBudrd70V2_AXSPOUTFz=...
It has happened to me in the past to wonder why certain files/folders are ignored by git, only to realise that I had a global git ignore for the particular pattern.
Not sure l’d recommend this as a good default, but perhaps others have better memory than I do.
The project-specific file is for stuff that should be shared amongst all users of a particular project. So for a Node project you might have `node_modules` in there, for a Python project you might have `.venv` and `*.pyc`. If your project uses env files, you might have a line like `.env` in there for that.
Meanwhile, the global gitignore is for stuff that's specific to your system. If you're on MacOS, you might have an entire for `.DS_Store`, or if you use Vim a lot you might have an entry for `*~` files (i.e. vim backup files). This is stuff that's specific to you.
Git can then combine the project-specific ignores (located in the project respiratory) and your user-specific ignores (located in your global gitignore file), and ignores anything that matches either case.
# OS
.DS_Store
# Editors
.vscode-server/
.idea/
# Javascript
.npm/
node_modules/
...more stuff per language
I find it really nice to just keep all that in one place and not have to configure it per project. There's nothing too broad or situational in there that might get in the way - those kinds of things can go into the project specific .gitignores.There's also `git status --ignored` to check if you're missing anything.
And also, sometimes I work from different machines and I don’t really want to have yet another dotfile to sync between all my current and future machines.
(Yes, I know dotfile managers exist, but I literally only care about syncing my zsh config files and one or two other dotfiles mainly so I do that with my own little shell script and basically don’t care about syncing other dotfiles.)
I just mean, it’s intentionally not a fancy setup with all kinds of things.
Just the most essential stuff and some symlinks. For the few dotfiles I really care about.
In an ideal world, I wouldn’t need any dotfiles at all. And my home directories would only contain files that I myself put there. Like my photos, my music, and code that I write. Those kinds of things.
That’s the main reason I don’t like managing all of my dotfiles. Because I don’t really want them in the first place. The only thing I want less in my home dirs but which I also have to live with is all of the other garbage that programs I use put there on their own. Like caches and different weird files that the programs decided should be there.
Just a view from the other end of the spectrum.
What would actually happen if I have a branch under development and it gets deleted from remote? Will it remove locally for me then? I guess only when my local head is equal to what remote pointed to.
You can see why you'd want to prune these on fetch, if you want your refs/remotes/alice state to mirror Alice's state; this means removing "alice/foo" if "foo" on Alice is removed. You also might not want to, that's fine. But if you use git fetch as though Git were a DVCS, this is exactly the natural behavior; it's only when you imagine Git is centralized that it starts seeming strange.
So the answer to your final question is "this is not how distributed VCSes work".
(Just don't ask about tags. Ugh, what a nightmare! To be fair, the idea is that you don't go around fetching tags.)
`gone = !git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D`
The remote reference would be deleted but your local one would not, and you could push your local right back up to the remote if you want. Pruning is totally safe.
https://github.com/dandavison/delta
(personally I think Difftastic's treesitter based approach is superior to Delta, yet I always appreciate it when people link alternatives when discussing apps so thought I'd add this for completeness' sake)
Since they're being too polite to shill themselves, I'll tempt HN by mentioning that GitButler is open-source and will soon be switching its underlying git support from libgit2 to gitoxide (a rewrite of libgit2 in Rust).
[1]: https://blog.gitbutler.com/gitbutler-is-now-fair-source/
Another nice thing would be a way to exclude file specs in git diff (Hack: add 'true' as a diff program in .git/config and use .gitattributes to exclude by setting diff=true).
Under the hood `git pull` is just `git fetch`+`git merge` so these two configs together would ideally enable the behavior requested (but unfortunately don't):
[fetch]
all = true
[pull]
ff = only
I also disable fast-forwarding with `git merge` since I prefer the branch topology you get without it. This doesn't break natural `git pull` fast-forwarding either, thanks to the above config: [merge]
ff = false
Commands to set all these: git config --global fetch.all true
git config --global pull.ff only
git config --global merge.ff false(we're in branch A)
>git pull
...
From ...
rev1..rev2 A -> origin/A
rev3..rev4 B -> origin/B
Updating rev1..rev2
Fast-forward
---
The fast-forward is on branch A. I'd like the git pull to also fast-forward branch B (and branches C,D,Etc.). They're usually by other devs, I don't usually check these, but when I do, I could save an extra command when switching if git just moved the branch head with the data it already has.
git checkout origin/A
There's no reason to clutter `git branch list` output with branches I don't care about.Your idea is interesting, didn't know that's useful. Detached head is a bit annoying though.
Thinking on this more I think I'd prefer changing `git checkout/switch <branch>` to automatically use `origin/<branch>` instead (like mook mentions in a sibling comment), rather than changing the `git pull` behavior.
Keeping the local branch refs in place after `git pull` lets you still easily see the local vs remote differences when running `git log`. Changing the behavior of `git checkout` or whatever you use to switch branches to auto fast-forward seems to be a way to have your cake and eat it too, almost.
But, clearly you've thought more on this than I have (having just learned about it lol), what do you think?
[alias]
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
https://learngitbranching.js.org/charmbracelet/git-lfs-transfer: https://github.com/charmbracelet/git-lfs-transfer
jj-vcs/jj: https://github.com/jj-vcs/jj
Also I wish GitHub and GitLab had colorMoved.
Edit: or go third-party? https://github.com/jgavris/rs-git-fsmonitor I don't have any experience with it though.
*.swp
It could clobber other tools' file endings, though.
[core]
pager =
[pull]
ff = only
I don't want git to start a merge without my explicit request, hence the ff-only on git pull. Similarly, opening a pager without me explicitly asking for it is an antipattern and I can't stand tools that do so by default. My terminal has scrollback history TYVM. [push]
default = upstream
I think this is the default now anyway, but I don't want git assuming anything about remote-local branch relationships. [alias]
tlog = log --graph --oneline
Simple git tree-log shorthand. [status]
showStash = true
[stash]
showPatch = true
I always tend to forget when I stashed something, so I need the explicit reminder. The second one makes git stash more like git show.[interactive] singleKey = true
and I'd recommend are
[gc] reflogExpire = never reflogExpireUnreachable = 150 (or another high number)