News for hackers. Stuff that matters.
Re:Highlights from Git 2.28 by neves on Monday July 27, 2020 @06:08PM (#23969993)
I'm a somewhat advanced user of Git. My coworkers use me as a reference when they have a problem of a difficult merge to solve.

I don't follow each Git release, but I also didn't notice a great productivity enhancement for a long time. Sure it is a sign of a mature project, but I'd like to know:

What's the somewhat recent Git feature that you really improved your productivity?

Re:Highlights from Git 2.28 by jacobparker on Monday July 27, 2020 @06:25PM (#23970138)
For the past few years the performance work (e.g. commit graph) has made a huge difference for large/fast moving repos. They're big enough to be productivity enhancements for some people: when we merged our Android-like multi-repo setup into a proper mono-repo we required updating git because things like git status/git commit/git log could take minutes without the recent perf fixes.

It pays to follow the release notes because some of these features are opt-in (e.g. commit graph is still optional).

The sparse checkout stuff is great but still too low-level for us to use, but it's laying the groundwork for something good.

Re:Highlights from Git 2.28 by mklein994 on Monday July 27, 2020 @08:40PM (#23971057)

  git range-diff
Very useful to get an overview of what changed after a rebase.

https://git-scm.com/docs/git-range-diff

Re:Highlights from Git 2.28 by nitemice on Monday July 27, 2020 @10:06PM (#23971606)
Thank you for mentioning this. I wrote my own bash script to do something similar ages ago, but I'm betting this will be much less janky.
Re:Highlights from Git 2.28 by lzutao on Monday July 27, 2020 @10:45PM (#23971810)
Really nice. I hope GitHub use this option soon.

Or maybe not: I guess it's kinda slow and heavy on computation.

Re:Highlights from Git 2.28 by mbakke on Monday July 27, 2020 @07:11PM (#23970485)
As someone doing lots of merges in a big and active project, git rerere has saved me hours whenever I need to redo a complicated merge.

It's not at all new according to a quick grep of RelNotes, but I only recently discovered it, so it is new to me.

Re:Highlights from Git 2.28 by acdha on Monday July 27, 2020 @08:32PM (#23970990)
Conversely, I hit that years ago (long-running migration tarpit) and forgot about it until I setup a clean home directory on a system which didn’t have my dotfiles repo and thought I’d hit a major Git regression. It saves you time on exactly where you need it the most.
Re:Highlights from Git 2.28 by mklein994 on Monday July 27, 2020 @09:15PM (#23971277)
git diff --color-moved

This makes git diff highlight reindented or moved lines differently.

I use it to get diffs similar to when you pass -w, but with a bit more context.

It takes a bit of experimenting to keep it from looking like a fruit salad, but sometimes you get interesting results.

https://git-scm.com/docs/git-diff#Documentation/git-diff.txt...

Re:Highlights from Git 2.28 by square_usual on Tuesday July 28, 2020 @02:04AM (#23972759)
If you use git diffs frequently, I recommend setting up delta: https://github.com/dandavison/delta
Re:Highlights from Git 2.28 by Myrmornis on Tuesday July 28, 2020 @10:19PM (#23982902)
And I am working on implementing color-moved support https://github.com/dandavison/delta/issues/72
Re:Highlights from Git 2.28 by setpatchaddress on Monday July 27, 2020 @08:29PM (#23970971)
git worktree.

Godsend if you regularly need to work on multiple branches simultaneously.

Re:Highlights from Git 2.28 by monocularvision on Monday July 27, 2020 @10:43PM (#23971795)
“Let me share the Good News of git worktrees” is a thing I say often in our work Slack.
Re:Highlights from Git 2.28 by jayd16 on Monday July 27, 2020 @09:53PM (#23971523)
What does worktree provide that a fresh local clone doesn't?
Re:Highlights from Git 2.28 by fiddlerwoaroof on Monday July 27, 2020 @10:15PM (#23971659)
Reduced disk space usage for large repositories. And a convenient way to manage all your clones
Re:Highlights from Git 2.28 by jayd16 on Tuesday July 28, 2020 @03:37AM (#23973298)
I guess it reduces duplicating the history? Large files are by far the bulk of what I personally deal with so it don't think there's a real difference for me but I could see it helping.
Re:Highlights from Git 2.28 by fiddlerwoaroof on Tuesday July 28, 2020 @12:03PM (#23977153)
Yeah, it only stores the objects in the .git directory once.
Re:Highlights from Git 2.28 by e28eta on Tuesday July 28, 2020 @01:36AM (#23972624)
Maybe too obvious, but if you’re not pushing everything to the remote, local-only content is available in both worktrees.
Re:Highlights from Git 2.28 by MarkSweep on Monday July 27, 2020 @11:05PM (#23971901)
If it's a multi-gigabyte repo that you are cloning over a slow VPN, it speeds things up quite a bit.
Re:Highlights from Git 2.28 by iad on Tuesday July 28, 2020 @01:50AM (#23972696)
The `--reference` and `--dissociate` flags to `git clone` can be used to avoid the majority of the network transfer while still creating an independent local repository.
Re:Highlights from Git 2.28 by jayd16 on Tuesday July 28, 2020 @03:33AM (#23973281)
Like I said, I'd usually just clone locally, as in clone from the repo you already have on disk.
Re:Highlights from Git 2.28 by merb on Monday July 27, 2020 @07:16PM (#23970508)
git switch/git switch -c so much better than git checkout and the confusing switches.
Re:Highlights from Git 2.28 by imron on Monday July 27, 2020 @10:06PM (#23971605)
Not for me.

Those confusing switches are already ingrained in my memory (or hidden away behind aliases) and now I find it more confusing that git is recommending new and different commands to do things that I've been doing a fixed way for years.

`git restore <file>` instead of `git checkout -- <file>`is another one.

Re:Highlights from Git 2.28 by merb on Tuesday July 28, 2020 @04:22AM (#23973583)
well git checkout basically is confusing because it does two things at once.

git restore and git switch basically tries to seperate the functionality.

i.e. from: "git-checkout - Switch branches or restore working tree files"

to

- "git-switch - Switch branches"

- "git-restore - Restore working tree files"

tbf I found it really stupid from the beginning that it tries two things at once.

Re:Highlights from Git 2.28 by nitemice on Monday July 27, 2020 @10:14PM (#23971652)
Well, I guess the good thing here is that they're not going to remove the old checkout behaviour. And these new commands are much easier to use and understand for a beginner.
Re:Highlights from Git 2.28 by SomaticPirate on Monday July 27, 2020 @11:59PM (#23972145)
Setting up watchman as a Git hook for fsmonitor.

It speeds up git status on large codebases

https://github.com/git/git/blob/master/templates/hooks--fsmo...

Re:Highlights from Git 2.28 by kakawait on Tuesday July 28, 2020 @10:40AM (#23976281)
Sparkle/partial checkout for big repo or legacy or people doing shit with git
Re:Highlights from Git 2.28 by UkiahSmith on Monday July 27, 2020 @06:18PM (#23970081)
git restore
Re:Highlights from Git 2.28 by mpawelski on Wednesday August 05, 2020 @07:07AM (#24059397)
+1 this.

It's not just better name for doing "git checkout -- path". "git checkout" has this stupid behavior of restoring files to worktree and index. "git restore" by default doesn't touch index (I wrote SO answer that explains this a bit more: https://stackoverflow.com/a/60855504/350384)

there is also "git switch" but I just kept using "git checkout" because there is nothing "git switch" can do that "git checkout" can (it's just a shorter name but I had aliased "checkout" to "ch" anyway, as many people do)