ElectricRCAircraftGuy / eRCaGuy_dotfiles

.bashrc file, terminal prompt that shows current git branch, Arduino setup, Eclipse setup, git diff with line numbers, helpful scripts, improved Linux productivity, etc.
MIT License
209 stars 60 forks source link

Installing Git For Windows #27

Open ElectricRCAircraftGuy opened 1 year ago

ElectricRCAircraftGuy commented 1 year ago

Installing Git For Windows

When installing Git For Windows, which also has Git Bash, be sure to check the box for (NEW!) Add a Git Bash Profile to Windows Terminal, as shown in blue here in the Git 2.42.0 setup:

Screenshot from 2023-08-21 22-48-27

Choose Sublime Text as your git editor (Sublime Text should have already been installed).

Override the branch name, and set it to main:

image

For line endings, I prefer to use Unix style line endings (LF), instead of Windows style (CRLF), even on Windows. So, choose the core.autocrlf = input option, as shown here:

image

Check the box to enable symbolic links:

image

Check these two boxes too:

image

Fix the ~ (HOME) dir in Git Bash, if necessary

Update: see my new answer here to solve this problem: Change the location of the ~ directory in a Windows install of Git Bash

My original notes:

I've noticed, and I don't know why, that sometimes Git Bash sets your HOME (~) directory to /u/, which is super weird, instead of to /c/Users/myusername. To check this, run echo ~ or echo "$HOME" (same thing). If you see /u/, that's not right. You should see something like /c/Users/myusername instead. The first / in an absolute path in Linux or in Git Bash represents the filesystem root, just like C:\ does in Windows.

  1. So, if your HOME dir is not right, open up the profile file in your Git Bash root folder in a text editor. It is located at C:\Users\myusername\AppData\Local\Programs\Git\etc\profile, for example. If you have MS VSCode installed, you can open this file for editing in VSCode by running the following in Git Bash:

    # open this file for editing in VSCode
    code /c/Users/$USERNAME/AppData/Local/Programs/Git/etc/profile

    Add the following to the very top of this file. Be sure to use Linux-style forward slashes (/), not Windows-style backslashes (\), in the path. Note that "GS" here is just my initials, so I can be reminded that I made this change and added this comment:

    # GS: Manually fix the HOME dir
    HOME="/c/Users/$USERNAME"

    Save and close the file when done.

  2. Close and re-open any Git Bash terminals you have open, to finalize this change.

  3. Run echo ~ or echo "$HOME" again to verify that the home folder is now set correctly, and now shows /c/Users/myusername.

Also do this

  1. My answer: Stack Overflow: Python doesn't work in Git Bash (it just hangs or freezes forever); and getting Linux hash-bangs to work in Windows

See also

  1. My answer: Stack Overflow: Adding Git-Bash to the new Windows Terminal
  2. My answer: Stack Overflow: Installing & setting up MSYS2 from scratch, including adding all 7 profiles to Windows Terminal
ElectricRCAircraftGuy commented 1 year ago

I just referenced my instructions above in my new answer here too: Adding Git-Bash to the new Windows Terminal.

ElectricRCAircraftGuy commented 12 months ago

See also my answer:

Installing & setting up MSYS2 from scratch, including adding all 7 profiles to Windows Terminal