|

Git tricks

Last week I came across a great talk about git, from Scott Chacon, one of the GitHub founders. While, as he said, that could be a boring tech talk to some, I found it really useful and he delivered it in a very entertaining way, so here is link if you wanna see it.

Listing my few favourite take aways below: 

Conditional configs:

includeIf

adds conditional configuration for different projects

git blame -L

Performs git blame on specific lines of the file, making it easier to perform checks

git log -L

Same, but with git log – shows the history of a specific the function or lines of code.

git blame -w

Performs git blame, ignoring the white space.

git blame -w -C -C -C

Blame looking in all commits, ignoring the white space – useful in refactoring and moving code between files 

git reflog

See the reference logs – easier way to track the merges and branches references.

git config —global rerere.enabled true

Reuse Recorded Resolution – remembers how you fix merge conflicts and fixes automatically 

git maintenance start

Adds config for a cron job to do maintenance, speed things up on monorepos and big repositories in general, by performing hourly checks and fetch.

Monorepo

git sparse-checkout

Gets only the needed directories from a mono repo, but makes it look like you have all of them locally.

These are also described in a way more detail in his new project blog – https://blog.gitbutler.com/ , take a look and pick your favourite! 

Similar Posts