What is the Magit equivalent of git add [--intent-to-add] <filename> for checking a newly created file into Git?

  • At some point, perhaps someone will put together a cheat-sheet that converts command line options (in alphabetical order) to magical Magit keboard shortcuts. It should not be necessary (in my opinion) to read the manual -- that is why G*d created an index -- i.e., read just whatever is relevant to the task at hand. – lawlist Sep 3 '15 at 2:01
  • 1
    It doesn't map command line to magit, but there is a refcard: magit.vc/manual/magit-refcard.pdf. – tarsius Sep 3 '15 at 15:00
  • @tarsius: It would be sensible to add a "git add" index entry pointing to the "Staging and Unstaging" node of the manual. – phils Jun 21 '17 at 23:54

To stage a change press s with point on any "stageable change". This includes files listed below "Untracked files" and "Unstaged changes".

You can also expand the files below "Unstaged files" using TAB (also works for many other sections) to see the hunks. You can then stage an individual hunk, again by pressing s while point is inside it.

You can even stage just parts of a hunk using the region. To do that press C-SPC to mark the beginning of the region and then n a few times to move to where the region should end.

In order to git add --intent-to-add, use C-u s.

You can also unstage, discard, reverse, and apply changes in a similar fashion. This is described in more detail in the manual. In particular see Staging and unstaging, Applying, and Sections. Staging is also covered in Getting Started.

  • 5
    s will stage a file. But how can i just add file, so that git will start tracking file but not stage all changes? – ChillarAnand Nov 12 '15 at 11:48
  • 7
    @ChillarAnand You can now do that using C-u s. – tarsius May 24 '16 at 22:24
  • 1
    When the git config "showUntrackedFiles = no" is set, staging with "s" is not possible as the files are not displayed. In that case @glucas answer is the way to go. i.e "magit-stage-file". For those who are wondering why would someone disabled tracking files, the workflow is common when the main repo is managed by some other vc like perforce and git is used as a local vc within the vc then in such scenario disabling tracking speeds up significantly – Talespin_Kit Jan 17 '20 at 9:29
  • How to add all untracked files at once? – Emmanuel Goldstein Feb 2 at 4:06
  • Press s while point is on the section title "Untracked files". – tarsius Feb 2 at 9:02

Start with magit-status, then move to the file name under the "Untracked files" heading and hit s to stage it.


If what you're looking for is a way to add/stage a file directly from its buffer: try the command magit-stage-file. If you do that a lot you could bind it to a key.

As others have already pointed out, the more common way to stage/add files is from the magit-status buffer.

  • magit-stage-file asks for file to stage. Doesn't directly stage it – sprajagopal Sep 5 '17 at 15:52
  • That's not how it behaves for me. Also from the doc: "With a prefix argument or when there is no file at point ask for the file to be staged. Otherwise stage the file at point without requiring confirmation." – glucas Sep 5 '17 at 15:54
  • Ah, I see: For a new file it does in fact prompt. If the file already exists (and you are staging changes) it does so silently. Thanks for pointing that out. – glucas Sep 5 '17 at 15:59

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.