0

Is it possible in the git custom command to change the console bash directory?

My example code:

#!/bin/bash
# This is a test
cd /c/testfolder
ls

the code is working, but the cd only works on this block doesn't do any alteration on the bash. enter image description here

So what I need it is the console / change to /c/testfolder

HudsonPH
  • 1,838
  • 2
  • 22
  • 38
  • https://alanbarber.com/post/how-to-customize-the-git-for-windows-bash-shell-prompt/ may help. `MINGW64` is part of `PS1`. – ElpieKay May 31 '19 at 09:21
  • @ElpieKay Thanks, but I want a need is to make the cd works outside of the script block, I edit the question removing the MINGW64 mention. – HudsonPH May 31 '19 at 09:25

1 Answers1

4

It is not possible for a command or shell script to cause the shell / console's current directory to change.

(Unless you are executing the script in the shell itself using source / .. You can't do that with a git custom command because they are executed by a child process of git not by the console's shell.)

See Bash script to change parent shell directory for a more detailed explanation of the base problem.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216