I have included my git source + repo source name in the header of the emacs frame so that I can be sure which branch / repo I'm currently working with. I do this by setting this information in the bash shell through PROMPT_COMMANDand then getting the information when emacs starts up in init.el(or .emacs) using the command getenvto set the variable frame-title-format.
Here is what I do in ~/.bashrc:
PROMPT_COMMAND="export GIT_REPO_NAME=\$(git remote -v 2> /dev/null | grep \"origin.\*fetch\" | awk '{print \$2}' | sed 's,https://github.com/\(.\*\)/\(.\*\),\1,g'); export GIT_BRANCH=\$(git branch 2> /dev/null | grep \"^*\" | awk '{print \$2}')"
And here is what I do in ~/.emacs.d/init.el:
;;; Rest of init.el code
(setq-default
frame-title-format
(concat
"%f"
(if (getenv "GIT_BRANCH")
(concat " in [ " (getenv "GIT_BRANCH") "/" (getenv "GIT_REPO_NAME") " ]"))))
;;; All the other goodies in init.el
, , , , env, PROMPT_COMMAND pwd emacs. emacs , /, , .
, : - emacs git / , , git /?
:
gitRepoA (branch X)
|-> buffer1.txt
|-> buffer2.txt
gitRepoB (branch Y)
|-> buffer1.txt
|-> buffer2.txt
, emacs buffer1.txt () gitRepoA. buffer1.txt in branch X in repo gitRepoA
buffer2.txt gitRepoB ( branch Y) emacs, buffer2.txt in branch Y in repo gitRepoB. , , buffer2.txt in branch X in repo gitRepoA. .
, git status (, ..).
/ . , - . .