show current GIT branch name in windows command prompt
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
add a comment |
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
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
add a comment |
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
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
windows git branch command-prompt
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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.
By default, the git-bash environment shows what branch you are in.
add a comment |
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
)
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
By default, the git-bash environment shows what branch you are in.
add a comment |
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.
By default, the git-bash environment shows what branch you are in.
add a comment |
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.
By default, the git-bash environment shows what branch you are in.
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.
By default, the git-bash environment shows what branch you are in.
edited Nov 7 '17 at 15:23
macetw
596617
596617
answered Aug 21 '17 at 8:01
Amr Lotfy
1,48921434
1,48921434
add a comment |
add a comment |
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
)
add a comment |
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
)
add a comment |
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
)
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
)
edited Sep 19 at 18:05
answered Sep 19 at 17:58
Richard Liu
212
212
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Nov 10 at 4:43
answered Sep 19 at 18:26
dkb
1,08911322
1,08911322
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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