Skip to content

Instantly share code, notes, and snippets.

@utsav00
Last active February 17, 2024 03:59
Show Gist options
  • Save utsav00/cdf1375281c561982de2999bdd1e6a3c to your computer and use it in GitHub Desktop.
Save utsav00/cdf1375281c561982de2999bdd1e6a3c to your computer and use it in GitHub Desktop.

These are some commands/configs that I don't know or haven't used a lot at the time of writing but find them valuable to incorporate in my daily life

Configs

REuse REcorded REsolution

git config --global rerere.enabled Solve the same conflic automatically the next time it comes up

Setting config on different levels - local, global, system

There is a 4th secret option:

[includeIf "gitdir:~/projects/oss"]
    path = ~/.gitconfig-oss

Git will look for config in ~/.gitconfig-oss only when it matches ~/projects/oss directory

Branch

List branches in column (esier to see) and sorts them by the most recent commit

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

Safe force push

git config --global alias.fpush push --force-with-lease

Accept typo of 1 char

git config --global help.autocorrect 1

Blame

git blame

  • -w - Ignore whitespaces
  • -C - Look for code movement between files
  • Also checkout git column since you're here ;)

Maintenance

git maintenance start

What it does:

gc: disabled.
commit-graph: hourly.
prefetch: hourly.
loose-objects: daily.
incremental-repack: daily.

Remote

git ls-remote - PRs as actual refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment