6

Wondering if it's possible to indicate intent to add a file via magit.

The intension would be to stage parts of an untracked file for a commit but leave the rest rather than the default git add behaviour of adding the entire file (which might have various wip bits).

9

C-us on an untracked file invokes the --intent-to-add behaviour. You can then stage parts of the file as usual.

(Note though that you cannot unstage parts of the file as usual; so be careful of what you're staging.)

Edit: I've just noticed that Magit's ediff1 integration provides a great workaround for the inability to unstage selected parts in this scenario.

  • Type e on the staged file
  • Move to the .~index~ window, which contains the staged changes
  • Edit the content directly (but don't try to save the buffer)
  • Exit ediff with q from the control buffer
  • Confirm to Magit that you wish to update the index
  • Profit!

1 I'll assume that you already know how to drive ediff. If not, then (a) I highly recommend taking some time to get familiar with it, because it's great; (b) ediff-window-setup-function is the variable to customize to prevent it opening a separate frame for the control buffer; (c) It has its own manual at C-h i g (ediff)

  • Just dipping my toes into the water with ediff, will definitely be digging into it more. Thanks for the tips. – Anntoin Wilkinson Dec 6 '17 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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