Since Git is used on Windows, if you install Git for Windows, It came with something called Git Bash.
Git Bash allows you to type Linux commands on Windows. I used this because I thought it was convenient.
However, as I was using it, I got a little worried about it, so I changed the Linux commands that came with Git Bash so that they can be hit from the command prompt.
Caution In the first place, when installing Git for Windows, It seems that you can set the Git command to be used at the Command prompt. This article is for those who didn't make that setting. By the way, the OS is Windows 10.
The reason why I wanted to operate at the command prompt.
I just want to use it for a while, but in my environment I have to wait about 3 seconds. Only 3 seconds, but 3 seconds. It becomes stressful when piled up.
I'm touching Explorer and want to type a Grep command in this folder,
At that time, if it is a command prompt, in the folder bar (I do not know the official name ...),
Just type cmd
to make that folder the current directory
The command prompt will start.
In Git Bash, start it up, wait a few seconds, type the cd command and it's finally started.
So, at the genuine Windows command prompt Try to use Linux commands.
When I installed Git Bash A little supplement to why Linux commands can be used.
C:\Program Files\Git\usr\bin
If you visit, you will find a lot of exe files.
This seems to be the true identity of the Linux command running from Git Bash.
Familiar commands such as less.exe and ls.exe are lined up. Set environment variables so that you can run these files from the command prompt.
From the search window of the Windows Start menu Search by "Environment Variables"> "System Properties" Dialog> Environment Variables (I always forget how to open the environment variable dialog, so I've searched for an unforgettable method for this article. )
Opened earlier in PATH
C:\Program Files\Git\usr\bin
To add.
Caution Some command names overlap with Windows commands. (Find commands etc. exist in both Windows and Linux.)
The point here is that when you execute such a command,
If you want to give priority to Linux
Make sure you bring Linux above % SystemRoot% \ System32
.
Check the operation with the ls command.
Microsoft Windows [Version 10.0.18363.900]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\karintoMania\Desktop\gitTest>ls
test.PNG text.txt
It seems to have worked.
I want to use the Linux commands that came with Git Bash at the command prompt → Add the command path to the environment variable.
In the next article, which Linux command did you want to use in the first place? I want to write something like that.
Recommended Posts