상세 컨텐츠

본문 제목

Android studio Github 연동하고 Github에 공유된 프로젝트 가져오기 / 오류해결

오류

by 뽀사장 2024. 2. 27. 16:39

본문

728x90
반응형

 

Android studio에 github 연동하는 방법을 알아보면 Android studio에서 Terminal을 열고 git init을 넣으라고 한다

그렇게 했을 때 나는 아래와 같이 에러메시지가 떴다

 

 


git : 'git' 용어가 cmdlet, 함수, 스크립트 파일 또는 실행할 수 있는 프로그램 이름으로 인식되지 않습니다. 이름이 정확한지 확인하고 경로가 포함된 경우 경로가 올바 른지 검증한 다음 다시 시도하십시오. 위치 줄:1 문자:1 + git init + ~~~ + CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException


 

이럴 경우 Terminal종류를 git bash로 변경해주면 된다

 

 

Android studio 좌측 하단에서 Terminal을 열면 드랍다운 화살표 선택 후 git bash를 선택해준다

 

이제 다시 git init을 입력하면 잘 실행된다

만약 그래도 안된다면 Terminal을 종료 후 다시 켜보면 정상적으로 작동하는 것을 볼 수 있다

 

 

 

 

이제 Github에 Commit을 하려면 아래 내용을 입력해줘야 한다


git config --global user.name "이름"

git config --global user.email "이메일"


 

git config --global 으로 입력하면 이름과 이메일을 global설정 파일에 저장되고 git config --local 으로 입력하면 하나의 파일에만 저장된다 하지만 이럴 경우 새로운 파일을 만들 때 마다 다시 설정해야하는 번거로움이 있어서 보통은 global로 입력한다

 

 

그 다음 git add를 입력하면 또한번 경고창이 뜬다

 


warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/build.gradle.kts', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/proguard-rules.pro', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/androidTest/java/com/example/team/ExampleInstrumentedTest.kt', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/java/com/example/team/MainActivity.kt', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/drawable/ic_launcher_background.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/drawable/ic_launcher_foreground.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/layout/activity_main.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/mipmap-anydpi/ic_launcher.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/mipmap-anydpi/ic_launcher_round.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/values-night/themes.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/values/colors.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/values/strings.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/values/themes.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/xml/backup_rules.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/main/res/xml/data_extraction_rules.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'app/src/test/java/com/example/team/ExampleUnitTest.kt', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'build.gradle.kts', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'gradle.properties', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'gradlew', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'settings.gradle.kts', LF will be replaced by CRLF the next time Git touches it


 

엄청나게 긴 에러메시지에 그냥 관둘까 생각도 했는데 다시 찾아보니까 줄바꿈의 문자열을 어떻게 할지 몰라서 뜬 에러였다

나는 윈도우기 때문에 아래와 같은 명령어를 입력해줬다

 

git config --global core.autocrlf true

 

지금 작업하고 있는 프로젝트에만 적용하고 싶다면 --global을 빼면 된다

 

 

그리고 이번에는 깃허브에 공유되어있는 프로젝트를 가져오기 위해서 git bash를 열었다

저장위치를 면경하고 싶다면 cd를 입력 한 후 위치를 지정해주면 된다

 

나는 유저폴더가 한글로 된 폴더라서 위치를 새로 지정해주지 않으면 에러가 난다

 

위치를 지정 해줬다면 git clone 프로젝트주소를 입력해준다

그런데 나는 또 에러가 났다

 


fatal: could not create work tree dir '프로젝트명': Permission denied


 

저장하려는 폴더의 권한이 제한되어있어서 그런거라 폴더의 권한을 확장시켜줘야했다

레지스트리 추가하는 방법도 있다고 하는데 예전에 레지스트리 잘못 건드렸다가 힘들었던 적이 있어서 안전한 방법을 택했다

 

우선 저장하고자 하는 폴더를 우클릭 후 속성으로 들어가서 보안선택을 하고 Users뒤에 PC명이 있는것을 선택해서 사용권한을 모두 부여한다

하지만 나는 또 오류가 났다

 


컨테이너의 개체를 열거하지 못했습니다. 엑세스가 거부되었습니다.


 

진짜 다때려칠까 싶었다 ....

아무튼 이렇게 뜨는 폴더의 권한설정은 불가능하다 (내기준)

 

그래서 권한설정이 가능한 폴더를 찾은 후에 다시 git bash에서 cd를 이용해 위치지정을 해주고 프로젝트를 clone한다면 제대로 받아서 작업할 수 있다

728x90
반응형

'오류' 카테고리의 다른 글

Github로 팀 프로젝트 첫 협업과 오류  (0) 2024.02.29
버전과 오류  (0) 2024.02.14

관련글 더보기