반응형

발생 Error

Git Bash에서 다음 명령어를 입력할 경우,

git ls-files

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

Error 발생

 

 

Error 원인

Git Bash가 실행된 폴더에 git에 대한 정보를 담은 파일이 없기 때문에 발생

 

Git Bash를 Window 검색창에서 실행시켜서 .git 폴더에 대한 탐색이 Local C\user\사용자명에서 일어난 것으로 추정

(추후, init으로 인해 .git 폴더가 Local C\user\사용자명에 생성되었으므로 위와 같이 추정)

 

 

해결 방법

git init
git remote add origin repository_url

git init을 통해 Git 저장소를 생성(초기화)하기

-> .git이라는 하위 폴더를 생성해서 해당 폴더를 git으로 관리할 수 있게 해줌

-> 작업이 필요한 곳에서 init 명령을 실행함으로써 현재 디렉토리에서 작업 및 버전 관리를 진행하겠다고 git에게 알려주는 기능

 

git remote add origin repository_address(Github 레포지토리 주소)를 입력해서 해당 repository를 local PC에 생성시킴

-> origin이라는 이름의 저장소(repository_address)를 추가

-> 원격저장소의 주소를 직접 입력하는 대신 origin이라는 이름을 사용할 수 있음

(⭐ git bash 명령어: 복사(ctrl+Insert), 붙여넣기(shift+Insert))

 

➕ 원격 저장소에서 데이터 가져오기: pull & fetch & clone

pull: 원격 저장소의 소스를 가져오고 해당 소스가 현재 내 소스보다 최신 버전일 경우, 지금의 버전을 해당 소스에 맞춰 올림, merge 명령어를 사용

: 원격 저장소에서 fetch 명령어로 가져온 후, merge까지 한 번에 수행하는 명령얼 실제 파일의 내용이 변경됨

git pull origin(remote_name) master(branch_name)

 

fetch: 원격 저장소에서 소스를 가져올 뿐 merge는 하지 않음

git fetch remote_name

 

clone: 원격 저장소에서 프로젝트를 가져오는 역할로 로컬 저장소와 원격 저장소의 내용을 일치시킴

git clone remote_url

 

victolee님의 티스토리 git 명령어 포스팅 일부 발췌

 

 

 

참고 자료

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

📑 Git Init/Add

📑 2.5 Git의 기초 - 리모트 저장소

📑 [git] git을 이용한 버전관리 - 기본편 (remote, push, pull, fetch, clone) with github

📑 [Git] git pull 소개와 git clone과의 차이점

📑 [Git] 명령어(2) - remote, push, clone, pull

반응형
반응형

 

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에 정리해야겠다.

 

 

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

 

반응형
반응형

Github Web에서 폴더 이름을 변경하는 것은 정확히 새로운 폴더를 만들어서 기존의 파일을 옮겨주는 작업이다.

그러므로 폴더 내 다량의 파일이 존재할 경우, Git Bash를 이용하는 것이 좋다.

 

1. 이름을 바꾸고자 하는 폴더에 들어있는 파일의 수정하기(Edit this file) 클릭

(⭐ 파일을 Guthub Web에서 수정하고자 할 때는, Commit한 내용이 아닌 파일/폴더명을 클릭해줘야 한다.)

 

2. 폴더 이름을 바꾸고 커밋

폴더_이름/: 폴더 생성

/상태에서 Backspace: 폴더 이름 변경

../: 앞의 폴더 이름 전체 삭제

 

 

 

참조: [Github] 깃허브에서 폴더 이름 변경하는 법

반응형