HudsonPH
HudsonPH

Reputation: 1878

Git - Custom command "cd"

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

Upvotes: 0

Views: 126

Answers (1)

Stephen C
Stephen C

Reputation: 719249

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.

Upvotes: 4

Related Questions