반응형
untracked 상태로 만들기에 앞서서 잠시 기초를 점검해보자.
워킹디렉토리 내부의 파일 또는 폴더를 스테이지 영역으로 등록하기 위해서는 git add '파일이름' 또는 '폴더이름'을 작성하면 된다.
파일인 경우
git add index.html
폴더인 경우
git add index
전체 파일과 폴더인 경우
git add .
git status로 확인해보면
참고로 git bash에서 확인하면 'new file:' 관련 부분들이 초록색 글씨로 되어있다.
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: springstudy20240224_homework/.classpath
new file: springstudy20240224_homework/.project
new file: springstudy20240224_homework/.settings/org.eclipse.jdt.core.prefs
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalAdd.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalDiv.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalMul.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalRem.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalSub.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/CalculatorAssembler.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/ChoiceNumAndCal.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/ICalculator.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/MainClass.class
new file: springstudy20240224_homework/bin/spring_chapter02_homework/MyCalculator.class
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalAdd.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalDiv.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalMul.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalRem.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalSub.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/CalculatorAssembler.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/ChoiceNumAndCal.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/ICalculator.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/MainClass.java
new file: springstudy20240224_homework/src/spring_chapter02_homework/MyCalculator.java
Untracked 파일은 빨간 글씨로 되어있다.
Untracked files:
(use "git add <file>..." to include in what will be committed)
.project
Calculator01.jar
Calculator01_1.jar
Calculator01_2.jar
bin/
springstudy0128/
springstudy0128_01/
springstudy0128_02/
springstudy0204/
springstudy0204_01/
springstudy20240212/
springstudy20240212_1/
springstudy20240217/
springstudy20240217_1/
springstudy20240218/
springstudy20240224/
springstudy20240224_1/
springstudy20240224_1_IoC/
springstudy20240224_2_DI/
이때 스테이지 영역에 등록된 파일 또는 폴더를 취소해야 할 필요가 생길 수 있다. 즉 tracked 상태의 파일 또는 폴더를 untracked 상태로 만드는 것이다.
그럴 경우에는 이 명령어를 사용하면 된다. 앞의 코드블럭을 봤다면 힌트를 얻었을 것이다.
아래의 폴더를 Untracked 상태로 만들려고 했는데 오류가 떴다. '-r' 명령어가 없다고 한다.
사용자git계정@사용자pc계정 MINGW64 /d/SpringPractice/project (master)
$ git rm --cached springstudy20240224_homework
fatal: not removing 'springstudy20240224_homework' recursively without -r
그래서 '-r' 명령어를 붙여 다시 실행해보니 rm 명령어가 실행됐다!
사용자git계정@사용자pc계정 MINGW64 /d/SpringPractice/project (master)
$ git rm -r --cached springstudy20240224_homework
rm 'springstudy20240224_homework/.classpath'
rm 'springstudy20240224_homework/.project'
rm 'springstudy20240224_homework/.settings/org.eclipse.jdt.core.prefs'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalAdd.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalDiv.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalMul.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalRem.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalSub.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/CalculatorAssembler.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/ChoiceNumAndCal.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/ICalculator.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/MainClass.class'
rm 'springstudy20240224_homework/bin/spring_chapter02_homework/MyCalculator.class'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalAdd.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalDiv.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalMul.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalRem.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalSub.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/CalculatorAssembler.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/ChoiceNumAndCal.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/ICalculator.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/MainClass.java'
rm 'springstudy20240224_homework/src/spring_chapter02_homework/MyCalculator.java'
사용자git계정@사용자pc계정 MINGW64 /d/SpringPractice/project (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.project
Calculator01.jar
Calculator01_1.jar
Calculator01_2.jar
bin/
springstudy0128/
springstudy0128_01/
springstudy0128_02/
springstudy0204/
springstudy0204_01/
springstudy20240212/
springstudy20240212_1/
springstudy20240217/
springstudy20240217_1/
springstudy20240218/
springstudy20240224/
springstudy20240224_1/
springstudy20240224_1_IoC/
springstudy20240224_2_DI/
springstudy20240224_homework/
nothing added to commit but untracked files present (use "git add" to track)
맨 밑에 Untracked files에 springstudy20240224_homework 가 다시 추가되었다.
git rm --cached <file>
폴더를 등록 취소할 경우에는
git rm -r --cached <folder> 를 사용하면 된다.
반응형
'개발일기 > github' 카테고리의 다른 글
github - git push가 되지 않을 때_1_The requested URL returned error: 403 (2) | 2023.12.03 |
---|