Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell Emacs my git branch has changed?

At the bottom of my Emacs 23 editor, I notice that Emacs is aware that I am working in a directory that is under version control, what that version control system is, and what branch I am currently on. Pretty cool! But say I am on the master branch, and from the command line I do a git commit, followed by a git checkout <branch>. Emacs still shows me being on the master branch. How do I refresh Emacs so that it reflects the branch I am currently on without closing down all my buffers and restarting it?

like image 339
Houdini Avatar asked Jun 11 '13 18:06

Houdini


People also ask

How does git keep track of current branch?

Git stores all references under the . git/refs folder and branches are stored in the directory . git/refs/heads. Since branch is a simple text file we can just create a file with the contents of a commit hash.

What is EMAC git?

Magit is a complete text-based user interface to Git. It fills the glaring gap between the Git command-line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks with just a couple of mnemonic key presses.


1 Answers

You can revert buffer automatically by enable global-auto-revert-mode. If you want to enable it, please add following code to your configuration file.

(global-auto-revert-mode 1)
(setq auto-revert-check-vc-info t)
like image 82
syohex Avatar answered Oct 17 '22 15:10

syohex