Hi there,
I'm using git for windows, version 2.9.0 in 64-bit. I'm not really sure, but in my memories the git-bash opened in the users home folder some time ago (c/users/username on windows 7).
The current version (and the last few versions, too) are opening the git-bash in root (/) and not in my user-folder.
Is this a bug, a feature, or are my memories wrong?
If my memories are wrong:
Configuring the .bash_profile to go to the home folder when it opens up breaks the "open git bash here" option, so is there a way to configure the git-bash to open up in home folders and not breaking the "open git bash here" option?
Greets, Jan
Try using pwd -W to find out what the true Windows path is to the putative current directory (of 'root')
there is a different file system philosophy between Windows and *nix. Windows has drives (plural) while *nix has root (singular).
So on G4W, a locally particular folder is chosen as the root directory, which depends on which bash exe you run. The SDK's bash and the program files bash can have different roots!
user@host MINGW64 /
$ pwd -W
C:/Program Files/Git
git-bash opened in the users home folder some time ago
That is _quite_ some time ago: 59d5f4343f796ae7d3d41e4a918e67c346645c8f
If you want it to open in the home directory, call it with --cd-to-home.
At least, my memories were right :)
Thx, that worked.
On my little netbook (XP!), I see (it's not on-net at the moment), with the two different bashes,
G4W recent:
Title bar: MINGW32:/c/Documents and Setting/Philip
Philip@po MINGW32 ~
$ git version
git version 2.8.4.windows.1
Philip@po MINGW32 ~
$ pwd -W
C:/Documents and Settings/Philip
Philip@po MINGW32 ~
$ cd /
(Title bar changed to: MINGW32:/)
Philip@po MINGW32 /
$ pwd -W
C:/Program Files/Git
SDK recent:
Title bar: /
Philip@po MINGW32 /
$ git version
git version 2.8.4.windows.1.3.ge328a54
Philip@po MINGW32 /
$ pwd -W
C:/git-sdk-32
Philip@po MINGW32 /
$ cd /
Philip@po MINGW32 /
$ pwd -W
C:/git-sdk-32
note the two different root directories!
Also note the different title bar prefixes
(maybe the SDK should say 'SDK' ;-)
At least, my memories were right :)
@ausminternet yep, but there was no official Git for Windows version with that behavior. In other words: it was fixed before the first official release of Git for Windows 2.x.
SDK recent:
Title bar: /
@PhilipOakley Have you called pacman -Syu recently? I get SDK-64:/c/WINDOWS/system32 with my SDK, consistent with this part of /etc/profile.d/git-prompt.sh (which is owned by the git-extra package, my current version being 1.1.113.24fa039-1):
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
@dscho I completely reloaded the SDK on the 7th June. (A previous attempt a couple of months ago at pacman -Syu had gone bad).
I moved/renamed my personal /git dir so I could bring it back without having lots of config hassles, deleted the old SDK and rebuilt afresh. Then put back my /git and made sure it was up to date.
When I install, I normally use the bash only install option. (and it's XP 32 bit ;-)
I had noticed that the PS prompt wasn't the same as the regular program files bash window, but too many other life issues to search it down.
@dscho, Was going to ask the dumb question: how do you get the git-extra package version? but Google saved me before I hit 'comment'.
pacman -Qe
...
git-extra 1.1.113.24fa039-1
..
meanwhile you said
my current version being 1.1.113.24fa039-1
so it looks as if it's up to date.
I had noticed that the PS prompt wasn't the same as the regular program files bash window
So you see the SDK-32 prefix in SDK's git-bash now?
From: Johannes Schindelin
I had noticed that the PS prompt wasn't the same as the regular program
files bash window
So you see the SDK-32 prefix in SDK's git-bash now?
Unfortunately no. Even after a restart.
The titlebar is still just "/" at startup of the bash, with a prompt of
Philip@PhilipOakley MINGW32 /
$
(colouring is approx green, purple, orange, with my colour settings)
Philip
Unfortunately no. Even after a restart.
Can you verify that /etc/profile.d/git-prompt.sh contains the lines I mentioned earlier?
Hi @dscho ,
yes, the lines are there, and the git-sdk.sh is present in the sdk directory (and not in the program files directory).
I'm at a bit of a loss in how to debug this (*nix start up) stuff, e.g. determining which actual scripts are being sourced.
side thoughts:
Is the TITLEPREFIX code meant to work in the 32bit XP?
Does/should the git-prompt.sh need a shebang line?
Did manage to add an 'echo xxx' at L#8 of the git-prompt scripts and can see they are both executing at startup.
@dscho I think this http://superuser.com/a/886247/596154 (competing title settings set in other PS1 settings) may have some useful insights. I don't have enough time at the moment to pursue it much further, but maybe later.
I may trigger an 'Aha' moment for you.
Is the TITLEPREFIX code meant to work in the 32bit XP?
Yes.
(competing title settings set in other PS1 settings) may have some useful insights.
Maybe you set your PS1 in $HOME/.bash_profile?
I'm at a bit of a loss in how to debug this
I typically debug this by inserting a set -x into the startup files. This tells Bash that it should output a trace of commands that are executed from now on, and maybe something there rings a bell?
I've found c:\git-sdk-32\etc\bash.bashrc#L44-46 would appear to have the PS1 line that's showing up in my SDK window. It appears to be conditional on MSYS2_PS1 existing . I'll try and play with that.
I'll try the -x trick now you've prompted me.
After posting I realised that TITLEPRFIX must be working, 'cos the other (progam file/git) window was working - sometimes one can't see the blindingly obvious...
@dscho, I tweaked the c:\git-sdk-32\etc\bash.bashrc#L42-47 and can confirm that the displayed prompt (with the SDK bash) is the default one from there, while that piece of code is missing from the C:\Program Files\ version. (see the extra "Hi-" before the $MSYSTEM ;-)
# If MSYS2_PS1 is set, use that as default PS1, otherwise set a default prompt
# of user@host, MSYSTEM variable, and current_directory
if test -n "${MSYS2_PS1}"
then PS1="${MSYS2_PS1}"
else PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]Hi-$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n\$ '
fi
I haven't started looking at how that file is 'created/fetched' during the SDK install yet, nor if we should simply define an extra MSYS2_PS1="$PS1" at the end of the C:\git-sdk-32\etc\profile.d\git-prompt.sh (perhaps as a workaround - looks like it works)
I've just done a fresh full install of the SDK, and of Git 2.9.0, on my wife's W7 home office PC, and it has exactly the same issue.
The c:\git-sdk-**XX**\etc\bash.bashrc#L42-47 is causing the PS1 from git-prompt.sh to be overwritten.
How do I determine which package it was that loaded the c:\git-sdk-**XX**\etc\bash.bashrc file ?
I'm thinking it was one of the many pacman installs.
How do I determine which package it was that loaded the c:\git-sdk-XX\etc\bash.bashrc file ?
You mean "installed" by "loaded"? If so, it is pacman's -Qo option. Mine says:
$ pacman -Qo /etc/bash.bashrc
/etc/bash.bashrc is owned by filesystem 2016.05-3
Thanks, sorry about the jotd (jargon of the day ;-) misunderstanding .
I did eventually find that invocation, and the follow up -Qi to get
Philip@PhilipOakley MINGW32 /
$ pwd -W
C:/git-sdk-32
Philip@PhilipOakley MINGW32 /
$ pacman -Qo etc/bash.bashrc
/etc/bash.bashrc is owned by filesystem 2016.05-2
Philip@PhilipOakley MINGW32 /
$ pacman -Qi filesystem
Name : filesystem
Version : 2016.05-2
Description : Base filesystem
Architecture : i686
URL : https://sourceforge.net/projects/msys2/
Licenses : BSD
Groups : base
Provides : msys2-base
Depends On : None
Optional Deps : None
Required By : dash
Optional For : git-extra
Conflicts With : None
Replaces : msys2-base
Installed Size : 88.00 KiB
Packager : Alexey Pavlov <[email protected]>
Build Date : Fri, May 27, 2016 9:21:49 AM
Install Date : Sun, Jun 12, 2016 2:32:18 PM
Install Reason : Explicitly installed
Install Script : Yes
Validated By : Signature
Philip@PhilipOakley MINGW32 /
$ pacman -Qo /c/Program\ Files/Git/etc/bash.bashrc
error: No package owns /c/Program Files/Git/etc/bash.bashrc
I've then had a look at the what I believe is the msys2-base package at msys2-base-i686-20160205.tar.xz at https://sourceforge.net/projects/msys2/files/Base/i686/ and see that compared to the file in that tar, at the end of the full SDK the file has been updated/overwritten.
So I'm still unsure which package or patch owns that particular version of the file. Any pointers on how to detect, during the install, if the file has been updated?
PS: should this be moved/copied to a fresh issue?
PS: should this be moved/copied to a fresh issue?
Usually I prefer this. With active and responsive contributors, I am of course trying to accommodate ;-)
Not a fix, but adding this snippit to ~/.bash_profile seems to reliably work around the issue for me without the side effect of breaking _Git Bash Here_. I'm using tje 2.9.0 64-bit installer release on Windows 7.
if [ "$PWD" = "/" ]; then
cd
fi
This approach breaks down, of course, if you actually _want_ to begin in the root directory. That's been exceedingly rare in my case, however.
If you want it to open in the home directory, call it with --cd-to-home.
I still think this is the correct solution.
FWIW my Git for Windows v2.9.0 64-bit's _Git Bash_ opens in the home directory, as it should. The shortcut installed into the start menu uses that --cd-to-home option.
The shortcut does indeed include the --cd-to-home option. As far as I can tell this is only an issue when invoking git-bash.exe directly, with the parameter omitted... double-clicking it from the file explorer, for example. I'd agree that launching it with the parameter is the most correct solution.
Personally, I like to assign a key sequence to the shortcut in cases like this. In my case Ctrl-Alt-G invokes the program menu shortcut from anywhere, with the relevant parameter included.
Same here, my git-bash defaults to home dir because of the --cd-to-home flag in the shortcut installed by the installer--since, well, for as long as I can remember--which is about at least the last two or three years.
@landstander668 That's exactly right! 😄
FWIW I had this problem too, because of user error:
The right way to pin it to the taskbar is to right-click the desktop icon and select "Pin to Taskbar" there.
Marius,
Philip
----- Original Message -----
From: Marius Gedminas
To: git-for-windows/git
Cc: Philip Oakley ; Mention
Sent: Tuesday, August 30, 2016 7:59 AM
Subject: Re: [git-for-windows/git] git-bash doesn't start in home folder on windows (#794)
FWIW I had this problem too, because of user error:
a.. install Git for Windows (latest version as of yesterday; git --version reports 2.9.3.windows.2)
b.. run Git Bash
c.. right-click the icon in the task bar and select "Pin this program to taskbar"
d.. close Git Bash
e.. click the taskbar icon to launch Git Bash --> starts in / instead of ~
The right way to pin it to the taskbar is to right-click the desktop icon and select "Pin to Taskbar" there.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
FWIW I had this problem too, because of user error:
- install Git for Windows (latest version as of yesterday; git --version reports 2.9.3.windows.2)
- run Git Bash
- right-click the icon in the task bar and select "Pin this program to taskbar"
- close Git Bash
- click the taskbar icon to launch Git Bash --> starts in / instead of ~
The right way to pin it to the taskbar is to right-click the desktop icon and select "Pin to Taskbar" there.
Ran into this exact problem after installing v2.30.0 of GitBash on Win10.
You can also right-click the Git bash icon that is in your Start menu and pin it to the task bar.
The one that doesn't work (doesn't set you to your user home) is when you right-click the running copy of gitbash and say pin to taskbar.
Most helpful comment
FWIW I had this problem too, because of user error:
The right way to pin it to the taskbar is to right-click the desktop icon and select "Pin to Taskbar" there.