42

This question:

Can you interact with the index/staging area with TortoiseGit?

takes the position that TortoiseGit's main function is not to eliminate the need for the git command line, and in general, I agree.

However, git-gui has a feature I use a lot (maybe to compensate for bad workflow): the ability to selectively stage or unstage hunks or lines from the current patch in order to split a bunch of interspersed changes into coherent changesets in multiple commits.

The command-line alternative (for me, at any rate) is a bit clunky, so, ideally, I'd like to do the same selective committing in TortoiseGit.

So far I haven't found a way to do this, and I suspect, from the answer to the other question, that it isn't possible. Can anyone confirm this, please?

Community
  • 1
  • 1
Brent.Longborough
  • 9,567
  • 10
  • 42
  • 62
  • 3
    The only client on windows that has full support for selective staging in the GUI I've seen so far is [SmartGit](http://www.syntevo.com/smartgit/index.html). Thus said it has weak sides too, comparing to TortoiseGit or GitExtensions. – Ivan Danilov Aug 07 '11 at 09:53
  • @Ivan Danilov: Thank you, SmartGit is love at first sight for day-to-day stuff. If you would like to make that into an answer, it'll compete very well... – Brent.Longborough Aug 07 '11 at 12:05
  • I've answered plus somewhat expanded my very concise comment so it be counted as real answer :) – Ivan Danilov Aug 07 '11 at 16:44
  • Git Gui also supports selective staging and commiting. – Th 00 mÄ s Jan 11 '13 at 14:13
  • @ThomasS: Yes, it does. If only it wouldn't get into a hung state so often on Windows, then I would be content to just use it; as it stands, I want something that works more reliably on Windows. (I suspect this is some kind of MSYS[2] or MinGW (the library) glitch, because I don't remember this ever happening on Linux, but it happens to me all the time here on Windows. Sometimes also with gitk, so it's probably a bug that TCL/wish.exe tickles, which is more likely to happen the more subprocesses a TCL program tries to read the output of.) – SamB Nov 06 '15 at 02:58

5 Answers5

55

Yes it does now: see issue 222 - it takes the same approach as TortoiseSVN where you:

  • right-click on file, choose "Restore after commit"
  • TSVN creates a copy of the file outside the working copy, the file is shown differently in > the commit dialog (maybe an overlay icon or a different color)
  • user can double-click the file to open it in TMerge or some other diff tool and undo all the changes that should not be committed, then save those changes
  • commit
  • after the commit is finished, the copy of the original file is moved back

(From TSVN Issue 68)

sappjw
  • 373
  • 1
  • 14
Duncan Smart
  • 31,172
  • 10
  • 68
  • 70
  • Duncan, thank you very much for that. I am now deeply in love with SmartGit, but to all the TSVN team, I say, don't be discouraged, keep up the great work; even though you have really spectacular competition, you're still amazing. – Brent.Longborough Feb 17 '12 at 12:50
  • 1
    It's nice to see the TortoiseGit team creating a good, GUI-oriented way of doing this, rather than the sloppy GUI-over-a-console-app way most other git-gui's do things. Now if they would only do the same for interactive rebase... – BlueRaja - Danny Pflughoeft Dec 12 '13 at 21:40
  • 3
    This isn't selective staging, though. It's a workaround. Selective staging means you can decide as you go _without creating a commit_ what you want and what you don't want. This doesn't. It is not correct to say that there is support for selective staging in TortoiseGit. – Len Jan 17 '18 at 01:30
16

The only client on windows that has full support for selective staging in the GUI I've seen so far is SmartGit.

Thus said it has weak sides too, comparing to TortoiseGit or GitExtensions.

For me, main showstoppers in SmartGit are:

  1. Inability to compare two revisions. You could only see diff between one and its parent (TortoiseGit can that).
  2. Inability (well, it is somewhat strange, it is possible I didn't found the way) to limit log to some folder if I don't interested in everything (TortoiseGit can).
  3. Integration with VisualStudio (somewhat subjective, but GitEx have it and it is very handy)

I remember that there was something else, but evaluating last version of SmartGit now I can't find it. Either it was fixed/added or I just forgot what thing I can't do that time.

In any case I'm using both GitEx and TortoiseGit for some things and for everything else console is the best tool.

Ivan Danilov
  • 14,287
  • 6
  • 48
  • 66
  • Thank you for the answer, and especially for introducing me to SmartGit -- I've fallen in love with it already. Clearly, the limitations you mention are valid, but as they don't form a significant part of my workflow, fine. (Others' mileages may vary, of course.) – Brent.Longborough Aug 07 '11 at 19:07
  • 1
    Just for the record, my current version of SmartGit (2.1.7:2012-01-23) *does* allow you to look at the log for a given single folder (contents) or a single given file, as well as the whole tree. – Brent.Longborough Feb 17 '12 at 12:47
  • 5
    Both TortoiseGit ans Git Extensions do, as of March 2012, support working with hunks. I think that the answer by Duncan Smart should be marked as answer for this question (no matter how good SmartGit is). – Borek Bernard Mar 07 '12 at 13:53
  • @Borek: Yeah, they have caught things up already, good update. – Ivan Danilov Mar 07 '12 at 19:10
  • Shoutout to [Sourcetree](https://www.sourcetreeapp.com/), as another Windows client which supports selective staging in a very intuitive format. I use TortoiseGit for almost everything, and I launch Sourcetree when I want to use staging features. – BTownTKD Jun 05 '16 at 16:04
6

SourceTree (https://www.sourcetreeapp.com/) has a very intuitive GUI for selective staging. It is made to integrate with BitBucket (it is by the same company after all), but can easily work with any git repository.

I do still use TortoiseGit in parallel, especially because of some nice features like the revision graph.

EwgB
  • 61
  • 2
  • 4
  • 1
    In the four years since I asked this question, I've moved on considerably, passing from TortoiseGit to Syntevo SmartGit, and finally ended up at SourceTree, which I find brilliant for almost everything (including not only BB, but also GitHub). The 0.5% I can't do in SourceTree, I do on the command line. – Brent.Longborough Jan 22 '16 at 17:32
  • sourcetree is great but it's a real shame they don't support linux – Renaud Jan 27 '20 at 11:46
6

From the look of issue 222, the "add -p" feature isn't implemented yet.

Could you add support for partially committing a file? (git add -p).
I understand the way TortoiseGit works is a bit different from the normal "git index", but still I would like to have support for this in some way.

I'd love to commit only a few changes of a file.
For example, only commit a single line fix of the file, and leave the rest remaining in the working copy.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

There is the pull request which implement this feature from year 2020, hope it will be merged ASAP.

https://github.com/TortoiseGit/TortoiseGit/pull/233

ollydbg23
  • 1,124
  • 1
  • 12
  • 38