b0rk,
@b0rk@jvns.ca avatar

working on a very short list of helpful command line git tools. so far I have:

what am I missing?

(I think GUI git tools are great too but that's not my focus right now)

Paxxi,
@Paxxi@hachyderm.io avatar

@b0rk as a windows user I really like https://github.com/dahlbyk/posh-git

omega,

@b0rk i really like https://github.com/Wilfred/difftastic for my diffs

graydon,
@graydon@canada.masto.host avatar

@b0rk The idea that git doesn't have to use the same mechanisms to identify difference.

E.g., for line based text use git rebase main but for XML documents (XSLT, XML, XSD,…) use git rebase -s subtree -Xours -Xignore-all-space main and your suffering is going to decrease.

mathias, (edited )
@mathias@fussenegger.pro avatar

@b0rk difftastic (https://github.com/Wilfred/difftastic) similar to delta but syntax aware.

Maybe fzf/fzy with something like https://github.com/junegunn/fzf-git.sh or custom aliases. E.g I have things like:

co-file = "!sh -c 'git ls-branch $1 \
| fzf \
| xargs git checkout $1 -- ' -"

And git absorb https://github.com/tummychow/git-absorb

aadriasola,
@aadriasola@ruby.social avatar

@b0rk tig and rg, (ripgrep) are very useful

b0rk,
@b0rk@jvns.ca avatar

so many great replies! some things that stood out to me:

matthewp,
@matthewp@c.im avatar

@b0rk I completely depend on gitui in my workflow. It's so nice to be able to quickly go in, do some git work, then exit back out to the cli.

metavida,
@metavida@hachyderm.io avatar

@b0rk My favorite git alias is:

please = push --force-with-lease

So cheerful and easy to remember to type “git please” when I need to force push!

pastorinni,

@b0rk using gitui for a couple of months and simply love it. The simple fact that I can visualize the file changes and navigate through them makes my life easy.

tekin,
@tekin@ruby.social avatar

@b0rk I love git absorb for simple fix ups: https://github.com/tummychow/git-absorb

Also these personal aliases:

Aliases to clean up merged/redundant branches: https://tekin.co.uk/2019/03/delete-untracked-files-from-your-git-repository

Alias for a nicer listing of recent branches: https://tekin.co.uk/2021/11/listing-most-recent-git-branches

And better diff hunks for Ruby, Python, etc: https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more

doekman,
@doekman@mastodon.nl avatar

@b0rk Print the URL of the remote origin of the current git repository.

https://gist.github.com/doekman/45acdb0ceedd9dc9dc6105d0b058b06a

sbesselsen, (edited )
@sbesselsen@hachyderm.io avatar

@b0rk I saw this video on “Oxidise your life” the other day that has suggestions for a lot of great Rust-based modern CLI tools https://youtu.be/dFkGNe4oaKk

Specifically, GitUI: https://github.com/extrawurst/gitui

oantolin,
@oantolin@mathstodon.xyz avatar

@b0rk Since you are using the expansive definition of "command line tool" that includes full-screen interactive textual user interface applications, I think magit should definitely be on the list. I hear there are people that use Emacs exclusively for magit!

https://magit.vc/

hrw,
@hrw@society.oftrolls.com avatar

@b0rk my favourite alias:

Git up = pull --rebase --autostash

And for contributing via mailing lists there is no better tool than b4.

Anarcat,
@Anarcat@kolektiva.social avatar

@b0rk i have a handful of aliases i use all the time that i get confused about when i'm on another machine: amend=commit --amend; co=checkout; d=diff; ru=remote update; rv=remote -v; s=status; and of course the horrendous lg=log --graph --pretty=format:'%Cred%h%Creset %s %C(bold green)(%a
r)%Creset %C(blue)<%an>%Creset%C(bold yellow)%d%Creset' --abbrev-commit -
-date=relative --no-show-signature :)

zhenech,
@zhenech@chaos.social avatar

@Anarcat funnily, I have the same lg alias, but can't remember when I used it last :D

Anarcat,
@Anarcat@kolektiva.social avatar

@zhenech those are all aliases i actually use all the time. i have ommitted dozen more aliases from my .gitconfig i actually never use :p

aburka,
@aburka@hachyderm.io avatar

@b0rk Yes lazygit is amazing (and you can embed delta inside it btw). I get confused using it for complicated rebases, find it easier to just do it the "real" way, but for simple everyday operations and editing, commit messages or reordering and squashing commits, it's great. It's kind of a GUI though depending on your definition.

skyfaller,
@skyfaller@jawns.club avatar

@b0rk I find gitui indispensable: https://github.com/extrawurst/gitui

It's how I learned about and started using some important git features, such as stashes. UIs like gitui are fantastic for discovery. It's just easier to tell what's going on in a repo by flipping thru gitui.

I also think it's fun to get an overview of a git repo with onefetch, but that's more for aesthetics and showing off: https://github.com/o2sh/onefetch

colinstu,
@colinstu@birdbutt.com avatar
jessica,
@jessica@chaosfem.tw avatar

@b0rk perhaps some useful aliases?

I set up “log-all” to show all branches, one-line, decorated logs … I’ll have to look at tig tho

I’m sure other people have useful aliases as well

flakm,
@flakm@hachyderm.io avatar

@b0rk maybe git-cliff for managing release notes and git-crypt for storing encrypted data inside the repository?

nasrat,

@b0rk while rewriting history is probably a not common workflow I think git-filter-repo might be worth having on a list of tools https://github.com/newren/git-filter-repo

zhenech, (edited )
@zhenech@chaos.social avatar

@b0rk useful git aliases? e.g. I have git please for git push --force-with-lease and git find X which is a git ls-files | grep X to quickly find files.

https://github.com/evgeni/vcsh_git/blob/devel/.gitconfig#L9-L11

alexcg,

@b0rk I'm loving lazygit, especially integrating it into Neovim. Completely changed the way I use git

pulkomandy,
@pulkomandy@mastodon.tetaneutral.net avatar

@b0rk

gws - to quickly see the status of multiple git repositories, fetch them all before going offline, …

https://github.com/StreakyCobra/gws

dcoderlt,
@dcoderlt@ohai.social avatar

@b0rk

I use https://github.com/scmbreeze/scm_breeze to get a pretty status and short numbered aliases for changed files, branches, etc. It also has short aliases for commands (like ga for git add), which may be too much for some users.

mhoye,
@mhoye@mastodon.social avatar
wonka,
@wonka@chaos.social avatar

@mhoye gitk is a GUI tool though.

@b0rk

z3rOR0ne,

@b0rk I wrote a bash shell script around git that can do the basics. It can add, commit, push, present emojis. It limits commit messages to under 50 characters. It can revert back your commit, help start a new project, and even create or delete github repos using their api if you use an access token.

https://codeberg.org/z3rOR0ne/bgit

It's not as good as lazygit and others, but I wrote it as a learning tool and actually use it everyday. It even has a simple install script and man pages.

b0rk,
@b0rk@jvns.ca avatar

@z3rOR0ne oh cool! was just talking to a friend about a similar idea the other day

z3rOR0ne,

@b0rk It's definitely a beginner bash project, but I humbly submit it as a simple wrapper around git. 🙂

jwd630,
@jwd630@mastodon.social avatar

@b0rk I am late to this, but if git aliases are on the table then one I like is

alias = ! git config --get-regexp ^alias\. | cut -c 7

which reminds me what all my aliases are via

git alias

similar to bash’s bare alias command.

b0rk,
@b0rk@jvns.ca avatar

@jwd630 wait what does this do?

jwd630,
@jwd630@mastodon.social avatar

@b0rk If you add that line to the [alias] section of your .gitconfig then from a cli git alias will list that and all your other .gitconfig aliases. Possibly I got it from https://stackoverflow.com/q/7066325/1124740 though ddg suggests lots of people have invented this.

codicil,

@b0rk I have a combination of editor bindings/aliases that let me open either:
-the current file
-the current line
-the current selection
in GitHub, so I can send links to people.

I also have directory-based identity (including SSH/GPG!), and a git whoami alias.

If nobody's said it yet, storing GPG keys and ssh key passwords in the macos keychain (or similar); I don't need to type either of them ever.

Global gitignore files, a concept more people should be aware of (so that if a new person joins a project, they don't need to add all their editor files to the project's gitignore.) There is a decent but somewhat unmaintained collection of these on GitHub.

I also have a terrible (but very useful) pile of hacks to run git hooks on every repo, while still running local hooks, whether via husky, pre-commit, or .git/hooks. This way I can scan for secrets before committing, or add Jira tickets to the commit messages automatically.

Can share any/all of these if interested.

avolkov,

@b0rk I second gitk. Nothing works as well as a tk tool that can be run from command line.

It gives very handy visualization of what is going on with branches in a repository.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines