11

How do git commit -p in magit?

Not have this section in man page

2 Answers2

12

The status buffer will show the unstaged changes. Move point to the changes that you want to stage, and call magit-stage (s). If you want to stage a subset of changes within a single hunk, you can select the lines with the region before calling magit-stage.

See the "Staging and unstaging" section of the manual for more information.

explaw
  • 25
  • 6
Kyle Meyer
  • 6,914
  • 26
  • 22
1

If you want to stage lines of codes you can do magit-status, then on one file in the list of unstaged files d, then I select the lines you want to stage, then s.

leontalbot
  • 111
  • 3
  • 1
    `d` runs `magit-diff-popup`. Why are you suggesting that? – phils Mar 14 '18 at 19:37
  • 1
    @phils Presumably, the idea is to press "d d" to get to a magit diff and then select and stage the desired change and stage those with "s". The answer could use a few more details though, IMO. – Qudit Mar 14 '18 at 22:39
  • 1
    I expect you're right; but it's very odd (to my mind) to suggest firstly going to the status buffer and then opening a diff buffer, given that all the diffs are available *directly within the status buffer*. I can't imagine many people would do it that way. – phils Mar 14 '18 at 23:05
  • @phils I use `magit-status` first because I like to see the list of unstage files and the one for already stage files. I go on one file changed in the unstage section then click `d`. I see all the changes for all the unstaged files. Then `C+space` to select to portion of code I want to stage, then `s`. Does that makes sense to you? – leontalbot Mar 15 '18 at 12:22
  • 1
    @leontalbot you can see all the unstaged changes and use `C-SPC` selection from the status buffer too. Why do you want to go to the diff buffer? – npostavs Mar 15 '18 at 12:29
  • @npostavs Oh, to stage lines of code instead of files. When a want to stage files then yes, but can you select lines inside status buffer? – leontalbot Mar 15 '18 at 14:07
  • 1
    Yes -- in exactly the same way. Expand the file, select a region, and type `s` to stage the region. – phils Mar 15 '18 at 20:32