Programming/Git/Setting up development environment in Git Bash
Introduction
If you are used to command line-based development, you may wish to set up your development environment within Git Bash, an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands.
Git Bash is included as part of the Git For Windows package. Download and install Git For Windows like other Windows applications. Once downloaded, find the included .exe file and open to execute Git Bash.
Installing Anaconda
Next, you need to install the Anaconda Python distribution on your system. You can download it from here. Once installed, conda won't be immediately available within Git Bash. Go into the directory where you installed Anaconda, then
.../etc/profile.d/
in that directory you will find a file called conda.sh. Add it to the end of your ~/.bashrc file:
echo ". ${PWD}/conda.sh" >> ~/.bashrc
If the path to conda.sh contains spaces, you should use instead
echo ". '${PWD}'/conda.sh" >> ~/.bashrc
Close and re-open Git Bash for the changes to take effect. You may see
WARNING: Found ~/.bashrc but no ~/bash_profile, ~/.bash_login or ~/.profile. This looks like an incorrect setup. A ~/.bash_profile that loads ~/.bashrc will be create for you.
That's not a problem.
Let's create a conda environment called "development":
conda create --name development
We then need to init bash,
conda init bash
close and reopen Git Bash, and activate the new conda environment:
conda activate development
Suppose we now want to do some C or C++ development. Let's install m2w64-gcc:
conda install -c conda-forge m2w64-gcc
We can now run
gcc
and
g++
Perhaps we also want to develop in Fortran. In this case
conda install -c conda-forge m2w64-gcc-fortran
Then we can run
gfortran
It's also useful to have Make:
conda install -c conda-forge make
so we can run
make
Ninja:
conda install -c conda-forge ninja
so we can run
ninja
Finally, CMake:
conda install -c conda-forge cmake
so we can run
cmake