More On The Magit Initial Status Page

A couple of weeks ago, I wrote about setting the initial visibility of Magit sections. It was a bit of a nuisance but without it I had large expanded sections that invited an inadvertent stage command that could freeze Emacs for up to a minute. The change worked well in that the sections were folded when I first invoked the Magit status page but I found that sometimes I’d still stage a large set of files by mistake. That’s because when I have to choose a file to stage, I often just type s and let Ivy give me a list to choose from. If the point was on one of the folded sections, it would stage everything in that section.

So the problem was that the initial status page opens with the point on one of the folded sections instead of at the Head section at the top. Given my success with controlling the initial visibility I felt confident that there would be a way of controlling the initial point position. It was a bit hard to find but easy to configure. It’s a configurable parameter if you like doing things that way. Otherwise simply add

(setq magit-status-initial-section nil)

to your init.el. You can set it start on any section but the nil says to start with it on the Head section at the top of the page. I’ve been running with this latest change for the last few days and so far I haven’t inadvertently staged a bunch of files.

This probably isn’t a problem for most of you because as Alan Third noted it’s easily solved by the judicious use of the .gitignore file but if it is, just set the initial point to the Head section. You can, of course, set it to any section if that suits your workflow better; see the documentation for the variable magit-status-initial-section for details.

This entry was posted in General and tagged , . Bookmark the permalink.