Set an environment variable in git bash

bier hier picture bier hier · Dec 9, 2015 · Viewed 125.5k times · Source

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?

Answer

chepner picture chepner · Dec 9, 2015

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