When I set an environment variable in git using the export command, where does that variable get stored? It's not in my .gitconfig file, and it doesn't appear to be added to my Windows environment variables.


Assuming you're using Git Bash (or any similar shell), then the environment variables set by export are just stored in memory. They're not persisted anywhere on the hard drive. When you quit the shell and start it again, you will therefore lose the variables you've set previously.

That's why you typically place environment variable settings in shell configuration files like ~/.bashrc, which are loaded on startup. (See also Bash Startup Files.)

Note that there is not a huge difference between doing, say,

export FOO=bar



The only difference is that variables set by export are also passed on to child processes of your shell, which makes them accessible for any commands you run.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.