6

In my mode line I can see if a buffer has unsaved changes (**- or a red x in my case, since I am using smart-mode-line).

Is there a similar way to display whether or not the file visited by the current buffer has uncommitted changes in Git or whatever VCS you are using?

elethan
  • 4,755
  • 3
  • 29
  • 56
  • If you don't mind using up a column next to the buffer instead of showing it on the mode line, [Git Gutter mode](https://github.com/syohex/emacs-git-gutter) might work. – Scott Weldon Feb 16 '16 at 23:50
  • 1
    @ScottWeldon I love git-gutter-mode, but I have to be in an area with changes in order to see that there are changes. I would like to be able to whether or not there are changes regardless of my position in the file. – elethan Feb 16 '16 at 23:57

1 Answers1

7

Well, vc does that by default. From its documentation (emphasis mine):

When you visit a file that is under version control, Emacs indicates this on the mode line. For example, ‘Bzr-1223’ says that Bazaar is used for that file, and the current revision ID is 1223.

The character between the back-end name and the revision ID indicates the "version control status" of the work file. In a merge-based version control system, a ‘-’ character indicates that the work file is unmodified, and ‘:’ indicates that it has been modified. ‘!’ indicates that the file contains conflicts as result of a recent merge operation (*note Merging::), or that the file was removed from the version control. Finally, ‘?’ means that the file is under version control, but is missing from the working tree.

JeanPierre
  • 7,323
  • 1
  • 18
  • 37
  • Thank you! It looks like I didn't look into this enough before asking. I guess I always looked when I already had changes in a file, and didn't want to undo all those changes to see what in my mode line changed. What you say is correct though, and with `smart-mode-line` the color of the branch name even changes! Thanks again for steering me in the right direction! – elethan Feb 17 '16 at 14:46
  • ? I only have Git:branch-name in the mode-line. Yes, I tested it in a basic Emacs. – yPhil Aug 01 '17 at 20:18
  • @yPhil Isn't your file modified? The `:` says that. – JeanPierre Aug 09 '17 at 11:48