본문 바로가기
기타/예외 처리(예외와 싸우는 당신을 응원합니다)

깃 터미널 설정부터 -bash: git: command not found 예외 처리까지

by 세계 최고의 AI Engineer_naknak 2023. 3. 25.

잡았다 요놈.

깃을 설치하고 터미널에 기본 프로필로 설정해보겠습니다.

저렇게 Git Bash가 안뜨는 분들 있죠?

차근 차근 따라하시면 금방 처리할 수 있답니다!

저기 설정으로 가셔서 json 파일을 열어줍니다.

왼쪽 아래에 있죠.

저는 vs 코드로 했어요.

그리고 아래와 같은 코드를 추가해주세요

"profiles": {
        "defaults": {},
        "list": [
        .
        .
        .
        
},
{
                "commandline": "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
                "cursorShape": "filledBox",
                "guid": "{05333954-0b01-4a63-aa6e-550c5e5d10c7}",
                "hidden": false,
                "icon": "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico",
                "name": "Git Bash",
                "startingDirectory": "%USERPROFILE%"
}

저기 있는 guid는 Globally Unique Identifier의 약자로, 전역 고유 식별자라는 의미를 가지는 식별자라고 하네요.

 

[guid]::NewGuid()

이 친구를 windowPowerShell에 넣어주면 알아서 생성해 줍니다. 이걸 넣어 주세요.

 

저걸 추가하고 cmd나 wt(window+R 실행에서 power shell 바로가기)를 exit 했다가 다시 들어가 주시면 Git bash가 보일 거예요!

 

그런데

MSYS라고 뜰거예요. 여기서 git --version을 해버리면 

git 명령어 찾을 수 없다는 짜릿한 문구를 볼 수 있을 거예요!

정말 짜릿하죠? 이제 이걸 해결해볼 까요?

깃을 실행하는 버전은 2가지가 있어요 하나는 MSYS이고 나머지는 mingw 이죠. 

이 둘의 차이점은

msys/git is linked against a dynamic library provided by MSYS2 to provide POSIX-to-Windows compatibility (POSIX emulation) in a manner similar to how cygwin does (MSYS2 is forked from cygwin), thus it requires the MSYS2 environment to be present to run.

git-for-windows/mingw-w64-x86_64-git on the other hand, is compiled using the MinGW compiler, which performs the translation to native Windows calls at compile time, which results in a much faster binary compared to the emulation approach, and does only require native Windows libraries to run.

이라고 해요. 간단하게 말하면 MSYS를 실행하기 위해선 MSYS2라는 환경이 필요하고 MINGW는 다른 환경 필요 없이 윈도우와 함께 돌아간다는 거죠.

지금 우린 MSYS의 git 경로 를 Json파일에 추가했기 때문에, 또 이를 구동하기 위한 환경이 구비되있지 않기 때문에 git command not found가 뜬 거죠!

그럼 이제 이걸 바꿔볼까요?

"commandline": "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l"

"commandline": "\"%PROGRAMFILES%\\git\\bin\\bash.exe\" -i -l"

 

 

위에 있는 usr 경로를 지워주세요!

그러면

짜잔~! git 명령어가 제대로 들어가는 걸 확인 할 수 있쥬?

저를 포함해서 git 설치에 애를 먹는 분들을 위해

열심히 삽질하면서 찾은 -bash: git: command not found 예외 처리였습니다.

이 글이 많은 분들에게 힘이 되길 바라며 저는 이만..

댓글