2021-08-17 11:10:36
git 저장소를 내려받아 로컬에서 작업할 때 알아두면 좋은 git 명령어.
$ git fetch --all
$ git reset --hard origin/master원격저장소(서버)에는 파일이 있고 로컬에도 파일이 있지만 로컬에서의 변동 추적을 중지하고 싶은 경우
$ git git update-index --assume-unchanged [filename (with path)]원복하고 싶으면 아래 명령어를 사용한다.
$ git update-index --no-assume-unchanged <file>무시한 파일목록
$ git ls-files -v | grep "^[[:lower:]]"로컬에 있는 특정 파일의 변동 추적을 중지하고 싶은 경우.
만약 원격저장소에 파일이 있다면 원격 저장소에서의 파일은 삭제한다.
$ git rm --cached [filename]위 명령어 실행 후 ‘git status’를 실행해보면 아래와 같은 메세지를 확인할 수 있다.
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: test.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.md추적이 중지 된 상태이다.
commit , push 하면 git 저장소에서 해당 파일이 삭제 되는 것을 확인할 수 있다.
로컬에 있는 특정 파일의 변동 추적을 중지하고 더 나아가 아예 삭제하고 싶은 경우
만약 원격저장소에 파일이 있다면 원격 저장소에서의 파일은 삭제한다.
$ git rm [filename]위 명령어 실행 후 ‘git status’를 실행해보면 아래와 같은 메세지를 확인할 수 있다.
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: test.md위 명령어 실행시 로컬에서는 바로 해당 파일이 삭제된다.
commit , push 하면 git 저장소에서 해당 파일이 삭제 되는 것을 확인할 수 있다.