본문 바로가기
DevOps/Git

[Git Bash] Github Repository 내 폴더 이름 변경

by HJ0216 2023. 1. 15.

 

Github 폴더 이름 변경을 검색하면 git bash에서 다음과 같은 명령어를 입력하라는 내용이 나온다.

(참조: [Git] 폴더 이름 바꾸기)

git ls-files // 폴더 및 파일 확인
git mv 현재폴더명 바뀔폴더명
git add .
git commit -am "commit message 입력"
git push origin master

 

따라서 Git Bash에 git ls-files를 입력하면 다음과 같이 나온다.

첫번째 명령어는 git을 입력 안해서 command not found error가 발생하였고,

두번째 명령어는 git을 입력했지만 fatal: not a git repository (or any of the parent directories): .git error가 발생하였다.

 

 

fatal: not a git repository (or any of the parent directories): .git

(참조: [해결 방법] fetal: not a git repository (or any of the parent directories): .git)

 

 

Error를 해결하고 다시 폴더명을 변경하려고 git ls-files를 입력하면 아무것도 안나온다.

 

Github에서 Pull해서 폴더와 파일을 끌어와야하나 해서 git pull origin main을 작성했는데, 새로운 branch를 만들어버렸다..

아닌가..? Github에는 아직 1 branch로 표시된다..

Github에 있던 파일이 local pc로 pull 되었다.

 

 

초심으로 다시 git mv 현재폴더명 바뀔폴더명을 입력해보면..

git add .에서 permission denied error가 발생한다ㅎ.

 

 

Permission: denied

(참조: [해결 방법] Permission denied)

사용자의 SSH keys가 등록되지 않아 접근권한이 없어서 발생한 것으로, 새로운 SSH keys를 생성하면 된다.

 

SSH keys를 등록하고나서도 Permission Error가 발생하길래 Git Bash를 강제로 종료했는데,

Another git process seems to be running in this repository.. 새로운 Error가 발생했다..

 

 

⭐  Another git process seems to be running in this repository

(참조: [해결 방법]  Another git process seems to be running in this repository)

같은 repository 안에서 다른 git process가 동작하고 있을 때 발생하는 Error다.

 

 

lock 파일 제거 후, git add .을 실행하는데,  this operation must be run in a work tree error가 발생했다.

lock 파일 제거하면서 .git 디렉토리로 이동을 했는데, .git 디렉토리 내부에서 git add .을 명령할 경우 발생한다고 한다.

 

 

⭐ this operation must be run in a work tree

(참조: [해결 방법] this operation must be run in a work tree)

cd ../으로 상위 디렉토리로 이동을 했다.

 

 

다시 처음부터 git mv Machine_Learning AI를 명령하니 fetal: bad source error 발생..ㅠ

 

 

fetal: bad source

(참조: [해결 방법] fetal: bad source)

이미 폴더명이 AI로 변경되어 Changed to be committed된 상태였다.

 

수정사항 없이, git commit -m "change the folder name"으로 커밋을 해주었다.

$ git commit -m "change the folder name"
[main 3dc0358] chane the folder name
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename {Machine_Learning => AI}/ann_model.py (100%)
 rename {Machine_Learning => AI}/useful_method_from_numpy.py (100%)

 

마지막으로 git push를 입력해주었는데 다음과 같은 안내를 받았다.

$ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

fatal: The current branch main has no upstream branch.

(참조: [해결 방법] fatal: The current branch main has no upstream branch)

 

안내대로, git bash에 다음내용을 입력한다.

$ git push --set-upstream origin main

 

Git Bash에서 폴더이름이 변경된다.

 

오늘 폴더명 변경하면서 만난 오류들을 따로 Git Category에 정리해야겠다.

 

 

마지막으로는 폴더 이름 변경한 기념으로..