When I punch from the windows gitbash command line:
set $HOME = c
and do :
echo $HOME
It does not set it to c? How can I change/set the value of an environment variable?
A normal variable is set by simply assigning it a value; note that no whitespace is allowed around the =:
HOME=c
An environment variable is a regular variable that has been marked for export to the environment.
export HOME
HOME=c
You can combine the assignment with the export statement.
export HOME=c
set do?$HOME (such that the unquoted expansion results in a single word), it sets the first three positional parameters to the values of of $HOME, =, and c, respectively. For example, set a b c; echo "$2" would output b.If you want to set environment variables permanently in Git-Bash, you have two options:
Set a regular Windows environment variable. Git-bash gets all existing Windows environment variables at startup.
Set up environment variables in .bash_profile file.
.bash_profile is by default located in a user home folder, like C:\users\userName\git-home\.bash_profile. You can change the path to the bash home folder by setting HOME Windows environment variable.
.bash_profile file uses the regular Bash syntax and commands
# Export a variable in .bash_profile
export DIR=c:\dir
# Nix path style works too
export DIR=/c/dir
# And don't forget to add quotes if a variable contains whitespaces
export ANOTHER_DIR="c:\some dir"
Read more information about Bash configurations files.
setx foo bar versus setx foo=bar). I misread what you were saying with that answer since you didn't mention setx.export JAVA_HOME="C:\Program Files\Java\jdk-11"
Verify it's been changed
mvn -version
NOTE: Don't verify this via
java -version
setx JAVA_HOME "C:\Program Files\Java\jdk-17"
NOTE: necessary to restart Git Bash first