show current GIT branch name in windows command prompt










8














Is is possible to display current git branch name in regular windows command prompt?

Let's say on windows 7 or 10.










share|improve this question

















  • 1




    git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
    – Daniel Luz
    Mar 16 '16 at 22:59











  • Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
    – CoR
    Mar 16 '16 at 23:36















8














Is is possible to display current git branch name in regular windows command prompt?

Let's say on windows 7 or 10.










share|improve this question

















  • 1




    git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
    – Daniel Luz
    Mar 16 '16 at 22:59











  • Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
    – CoR
    Mar 16 '16 at 23:36













8












8








8







Is is possible to display current git branch name in regular windows command prompt?

Let's say on windows 7 or 10.










share|improve this question













Is is possible to display current git branch name in regular windows command prompt?

Let's say on windows 7 or 10.







windows git branch command-prompt






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 16 '16 at 21:55









CoR

1,97442238




1,97442238







  • 1




    git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
    – Daniel Luz
    Mar 16 '16 at 22:59











  • Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
    – CoR
    Mar 16 '16 at 23:36












  • 1




    git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
    – Daniel Luz
    Mar 16 '16 at 22:59











  • Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
    – CoR
    Mar 16 '16 at 23:36







1




1




git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
– Daniel Luz
Mar 16 '16 at 22:59





git status shows your current branch on the first line. git branch -a lists all your local branches with the current one marked with a *. Is this what you want?
– Daniel Luz
Mar 16 '16 at 22:59













Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
– CoR
Mar 16 '16 at 23:36




Of course not :) You are talking about pure git commands and I am talking about win command prompt similar to bash from Linux.
– CoR
Mar 16 '16 at 23:36












3 Answers
3






active

oldest

votes


















2














You cannot do this from the Windows-based "Command Prompt." There is an environment, however, that can run on top of your Windows environment, that does.



After you run the Git windows installer and allow git to install, you can invoke git-bash from context menu.



Call Git Bash in the system menu



By default, the git-bash environment shows what branch you are in.



Screenshot of the git-bash running environment






share|improve this answer






























    2














    This is the git.bat I am using. I got the answer from the following link:



    https://www.nu42.com/2016/05/display-git-branch-windows-command-prompt.html



    First, create the git.bat file in a folder, then add the folder to the PATH and ahead of the line to git.exe (I assume you already have the git.exe installed in your computer). This will make sure every time you type git in your command line, the new git.bat will be triggered instead of the git.exe.



    @echo off
    git.exe %*
    set GITBRANCH=
    for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I

    if "%GITBRANCH%" == "" (
    prompt $P$G
    ) else (
    prompt $P $C$E[32;7;32;47m%GITBRANCH%$E[0m$F $G
    )





    share|improve this answer






























      0














      I am using babun
      It provides an awesome command-line view for git.
      It also supports context menu and can be open from any location on right-click.



      snapshot






      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36047706%2fshow-current-git-branch-name-in-windows-command-prompt%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2














        You cannot do this from the Windows-based "Command Prompt." There is an environment, however, that can run on top of your Windows environment, that does.



        After you run the Git windows installer and allow git to install, you can invoke git-bash from context menu.



        Call Git Bash in the system menu



        By default, the git-bash environment shows what branch you are in.



        Screenshot of the git-bash running environment






        share|improve this answer



























          2














          You cannot do this from the Windows-based "Command Prompt." There is an environment, however, that can run on top of your Windows environment, that does.



          After you run the Git windows installer and allow git to install, you can invoke git-bash from context menu.



          Call Git Bash in the system menu



          By default, the git-bash environment shows what branch you are in.



          Screenshot of the git-bash running environment






          share|improve this answer

























            2












            2








            2






            You cannot do this from the Windows-based "Command Prompt." There is an environment, however, that can run on top of your Windows environment, that does.



            After you run the Git windows installer and allow git to install, you can invoke git-bash from context menu.



            Call Git Bash in the system menu



            By default, the git-bash environment shows what branch you are in.



            Screenshot of the git-bash running environment






            share|improve this answer














            You cannot do this from the Windows-based "Command Prompt." There is an environment, however, that can run on top of your Windows environment, that does.



            After you run the Git windows installer and allow git to install, you can invoke git-bash from context menu.



            Call Git Bash in the system menu



            By default, the git-bash environment shows what branch you are in.



            Screenshot of the git-bash running environment







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 7 '17 at 15:23









            macetw

            596617




            596617










            answered Aug 21 '17 at 8:01









            Amr Lotfy

            1,48921434




            1,48921434























                2














                This is the git.bat I am using. I got the answer from the following link:



                https://www.nu42.com/2016/05/display-git-branch-windows-command-prompt.html



                First, create the git.bat file in a folder, then add the folder to the PATH and ahead of the line to git.exe (I assume you already have the git.exe installed in your computer). This will make sure every time you type git in your command line, the new git.bat will be triggered instead of the git.exe.



                @echo off
                git.exe %*
                set GITBRANCH=
                for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I

                if "%GITBRANCH%" == "" (
                prompt $P$G
                ) else (
                prompt $P $C$E[32;7;32;47m%GITBRANCH%$E[0m$F $G
                )





                share|improve this answer



























                  2














                  This is the git.bat I am using. I got the answer from the following link:



                  https://www.nu42.com/2016/05/display-git-branch-windows-command-prompt.html



                  First, create the git.bat file in a folder, then add the folder to the PATH and ahead of the line to git.exe (I assume you already have the git.exe installed in your computer). This will make sure every time you type git in your command line, the new git.bat will be triggered instead of the git.exe.



                  @echo off
                  git.exe %*
                  set GITBRANCH=
                  for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I

                  if "%GITBRANCH%" == "" (
                  prompt $P$G
                  ) else (
                  prompt $P $C$E[32;7;32;47m%GITBRANCH%$E[0m$F $G
                  )





                  share|improve this answer

























                    2












                    2








                    2






                    This is the git.bat I am using. I got the answer from the following link:



                    https://www.nu42.com/2016/05/display-git-branch-windows-command-prompt.html



                    First, create the git.bat file in a folder, then add the folder to the PATH and ahead of the line to git.exe (I assume you already have the git.exe installed in your computer). This will make sure every time you type git in your command line, the new git.bat will be triggered instead of the git.exe.



                    @echo off
                    git.exe %*
                    set GITBRANCH=
                    for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I

                    if "%GITBRANCH%" == "" (
                    prompt $P$G
                    ) else (
                    prompt $P $C$E[32;7;32;47m%GITBRANCH%$E[0m$F $G
                    )





                    share|improve this answer














                    This is the git.bat I am using. I got the answer from the following link:



                    https://www.nu42.com/2016/05/display-git-branch-windows-command-prompt.html



                    First, create the git.bat file in a folder, then add the folder to the PATH and ahead of the line to git.exe (I assume you already have the git.exe installed in your computer). This will make sure every time you type git in your command line, the new git.bat will be triggered instead of the git.exe.



                    @echo off
                    git.exe %*
                    set GITBRANCH=
                    for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I

                    if "%GITBRANCH%" == "" (
                    prompt $P$G
                    ) else (
                    prompt $P $C$E[32;7;32;47m%GITBRANCH%$E[0m$F $G
                    )






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Sep 19 at 18:05

























                    answered Sep 19 at 17:58









                    Richard Liu

                    212




                    212





















                        0














                        I am using babun
                        It provides an awesome command-line view for git.
                        It also supports context menu and can be open from any location on right-click.



                        snapshot






                        share|improve this answer



























                          0














                          I am using babun
                          It provides an awesome command-line view for git.
                          It also supports context menu and can be open from any location on right-click.



                          snapshot






                          share|improve this answer

























                            0












                            0








                            0






                            I am using babun
                            It provides an awesome command-line view for git.
                            It also supports context menu and can be open from any location on right-click.



                            snapshot






                            share|improve this answer














                            I am using babun
                            It provides an awesome command-line view for git.
                            It also supports context menu and can be open from any location on right-click.



                            snapshot







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 10 at 4:43

























                            answered Sep 19 at 18:26









                            dkb

                            1,08911322




                            1,08911322



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36047706%2fshow-current-git-branch-name-in-windows-command-prompt%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                                Edmonton

                                Crossroads (UK TV series)