The company I work for has a code repository deep within a folder structure, the path of which I have saved in a text file. As I was copying that path from notepad and pasting it into a cd
command for the hundredth time after launching git bash I began to get the feeling that I was wasting time. Being the good programmer that I am, spending an hour researching how to do something programmatically is obviously preferable to doing something that takes four seconds over and over again. However I have been disappointed to find that all of the readily-available solutions offer one of two recommendations which both feel more like workarounds than an actual config change:
- Create a shortcut and modify the "start in" field. This is not acceptable for me because I launch git from the start menu (windows key type "git"). I don't want to add the extra steps of navigating to the folder where I created the shortcut. Even if I give the shortcut a unique name such as "stupidshortcutname", I am not able to access this shortcut by searching in the windows start menu.
- Modify the Windows environment variable HOME. This is not acceptable because I still want cmd to launch in its default location of
C:\Users\MyUserNameHere
.
With some further research I also found the option of creating a file called .bashrc
in my C:\Users\MyUserNameHere
directory, and having this run cd <folder I want to go to>
, but this still feels pretty hacky for something that I feel should be a configuration somewhere.
Git has its own config files, I would be shocked if none of them allowed for setting the location git will default to launching in. Am I out of luck and/or being too picky?
CodePudding user response:
Create a batch file with name like LaunchGit.bat
& write the following command:
start F:\Program" "Files\Git\git-bash.exe --cd=D:\your\deep\workspace\path
Now you can launch it from desktop or place it in your Git home directory (and launch from there)
This may not be the most perfect solution, but it will solve your problem.
And ofCouse this is just an idea and you can change/improve it.
CodePudding user response:
Use git-bash configuration to change the directory, if this is what you want.
In ~/.bash_profile
(create it if it does not exist), add
cd /path/to/git/repository
The reason to use ~/.bash_profile
instead of ~/.bashrc
is because the latter is read and executed when an interactive shell that is not a login shell is started (if exists).