8

I'm looking for a good tool to help me when making git commits. (Maybe viewing history as well)

Specifically, I want something that allows me to, using a gui:

  1. Very easily add files, do patch-add, hunk editing, patch-checkouts, etc. I do this constantly, making it easy would be a great help. I don't want that feature to be secondary. I almost wish I could simultaneously group multiple uncommitted changes into different "pre-commits" that I could later decide the order on too, but I doubt anything supports that. It's a little tiring to do it all via CLI.

  2. Automatically warn about >50 character commit messages, force limit to 80 character length lines in messages, maybe wrap at 72 for indentation (Or a custom setting, but those defaults are fine) and ensure capitalization on first word, no period at end, etc. Heck, if it can warn about imperative mood that'd be great too. (Though I suspect that's much harder) I don't make these mistakes often, but I want something to catch them if I do.

  3. If possible, view history. I use Gitk for this, and rolling this all into one tool would be nice. Plus, Gitk is a little lacking visually.

I'd also like the following properties:

  • Easy to install and set up.
  • Should work with existing, private repositories that are self-hosted (IE, doesn't require some tie to Github/etc) This eliminates Git Kracken unfortunately.

For reference, my current workflow is:

  1. Make large lump of changes
  2. Go into command line, decide which of the groups of changes I want to commit first, and begin going through each file and do git commit add -p [filename], add all the relevant changes, edit or split hunks when necessary.
  3. Once all files are done for this commit, go into QTCreator, use the Tools->Git->Local Repository->Commit, write the message since it automatically line-breaks at 80 characters so I can't make a mistake.
  4. Go back into CLI and push if I'm going to
  5. Get the do git log to get the commit messages I made for other uses.

One tool to handle let me do all of that instead of a mixture of Gitk, command line and QTCreator would be amazing.

6
  • 1
    Not sure if it fits your bill: can you take a look at my answer here? Gitcola can do much of what you list, if I understood that correctly. I usually launch that when I want to split my changes across multiple commits, for example. And it also warns/alerts at too long commit messages (color goes from green via yellow to red, with red at ~80 chars).
    – Izzy
    Mar 10, 2020 at 21:39
  • Just tried git-cola for awhile - it definitely fits many of the requirements. Unfortunately, apparently it is impossible to edit hunks in the diff view and I do not know any way to do it aside from opening a command line to do so. I may end up using it anyways though as it still cuts out some of my tools needed. Mar 11, 2020 at 18:39
  • By "edit hunks" you mean "change contents"? OK, that I never tried. But marking and "add selection" works, did that a couple of times.
    – Izzy
    Mar 11, 2020 at 20:26
  • 1
    Yes. You can select what pieces of a hunk to either revert or stage, but you cannot actually change what is in the hunk, which is what I meant by hunk editing originally. IE, if I changed a line to both modify the name of a variable, and its value, I cannot make those into separate changes. They're part of the same hunk, on the same line. With git add -p and the e command, you can do that. Mar 11, 2020 at 20:38
  • I use Git Extensions. Jul 8, 2022 at 21:40

2 Answers 2

1

There is one git client that suits all your requirements - it's the git client integrated in Eclipse IDE - I believe it's called EGit. It's the ONLY GUI client that I've found that has ability to edit hunks (you can actually edit whatever you want, even without adding any hunk/line). It only has one downside, which is... Eclipse (; OK, two downsides - Eclipse & Java. Generally with each version it has more and more bugs/glitches, yet it is still the best thing I've tried.

As I stopped using Eclipse as my main IDE and debugger, I now use it as a git client only. Probably a strange workflow, yet the set of features it has outclasses any competition I've seen.

To be honest, I'm constantly looking for an alternative, however each client I've found doesn't have the first feature you mentioned. For me the ability to manually edit the staged hunks is a "must have", so if you found any other GUI client, let me know too (;

0

VSCode

I hate to admit it, but they've done the best overall job so far I think.

Install on Ubuntu 22.04:

sudo snap install --classic code

then launch it on the root of the repository of interest:

code .

After going into the "Source Control" tab (Ctrl + Shift + G) You can just select line ranges with the mouse, right click and:

Stage selected ranges

Copy of a demo video from https://stackoverflow.com/a/65649756/895245

enter image description here

Small complaints:

But it does have the key functionality:

  • you can make edits straight away on the side by side diff
  • staged changes are clearly unmarked from the non-staged area when you stage them, and go to the staged list instead

Compared to Eclipse's Egit mentioned at https://softwarerecs.stackexchange.com/a/78190/2066 , VSCode Git support is just much much better, e.g.:

and I have serious doubts if those will ever be fixed given the current state of Eclipse.

Tested on Ubuntu 22.04, vscode e8a3071e rev 116.

git-gui

This is decent compared to VSCode:

  • smaller footprint
  • can't edit lines on it, if you find an error you have to jump back and forth between your editor and git gui, and it doesn't auto-refresh, you have to click Rescan button
  • has the "add hunk" option, as well as "add selected lines" unlike VSCode which does not have the "add hunk" version

Install:

sudo apt install git-gui

Launch under repo:

git gui

To add an entire hunk right click on it and select:

Stage Hunk For Commit

If you want to add only certain lines of the hunk, you can also select the lines you want, right click them and:

Stage Lines For Commit

Screenshot that I had added to https://stackoverflow.com/a/1086585/895245

enter image description here

Tested on git-gui 0.21, Ubuntu 22.04.

Bibliography:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.