2

How can I have an empty file that will indicate which git branch is currently active, and make this work with git?

Repositories I work with have often several branches (ie: dev -> stage -> live).
Ideally, I would want to have something like an empty file named "_BRANCH_NAME" in the root, that will show me all the time on which branch am I working.

I have been playing with this and separate .gitignores, but without any luck because branches should merge at certain point.

Is this possible? Is there anything else I can do to mimic this?

Thanks!

Aram Boyajyan
  • 834
  • 2
  • 13
  • 31
  • 2
    Out of curiosity, why is a file a requirement? I've seen indicators of current branch in bash prompts: http://stackoverflow.com/q/15883416/504685 – Charlie Jan 04 '15 at 19:12
  • 2
    How about a git hook that creates an ignored file named by the current branch every time you checkout/commit/etc. – Chris Stratton Jan 04 '15 at 19:14
  • @Charlie - thanks for the link, will check it now. I'd like to have a file simply because it is always visible in IDE/text and file management programs (finder/explorer/nautilus). I've been working on some projects where each repository has 4-6 branches. This significantly minimizes the error. – Aram Boyajyan Jan 04 '15 at 19:16
  • @ChrisStratton thanks for an interesting idea, will think about it now. – Aram Boyajyan Jan 04 '15 at 19:21
  • @Charlie I checked the indicator and while it's handy, it's still not as prominent. Thanks again though. – Aram Boyajyan Jan 04 '15 at 19:38
  • 1
    @Ivanhoe123, there are similar indicators for many editors. I suspect that you'll have more luck using the many common shell / editor indicators out there than getting your file approach to work reliably. – ChrisGPT was on strike Jan 04 '15 at 20:58

1 Answers1

0

Hopefully, this is no longer needed, and most IDE out there clearly mentions the branch you are on.

Here is my VSCode Version: 1.25.1 (2018-07-11T15:43:53.668Z):

VSCode branch

It clearly mentions the branch at all time, as well as the number of commits I can receive (here '2') or send (0 yet).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250