git 사용 중, git pull 을 하였을 때 error 가 발생할 때가 있습니다.
그 중, "error: Your local changes to the following files would be overwritten by merge:" 메세지에 대한 간단한 해결 방법에 대해 이야기 하고자 합니다.
1. git pull (error message)
[stephen@fedora web]$ git pull
stephen@10.0.2.2's password:
Updating 77abdb9..844456f
error: Your local changes to the following files would be overwritten by merge:
web/package-lock.json
web/package.json
web/server.js
Please commit your changes or stash them before you merge.
Aborting
2. git status
[stephen@fedora web]$ git status
On branch master
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
modified: server.js
no changes added to commit (use "git add" and/or "git commit -a")
3. 해결 방법
Error Messag 중, "Please commit your changes or stash them before you merge." 을 참고하여 문제를 해결한다.
3.1 git stash
현재 상태를 임시로 저장(백업) 합니다.
[stephen@fedora web]$ git stash
Saved working directory and index state WIP on master: 77abdb9 blog - modify source code - add footer file
최신 버전을 pull 진행 합니다.
[stephen@fedora web]$ git pull
stephen@10.0.2.2's password:
Updating 77abdb9..844456f
Fast-forward
web/package-lock.json | 327 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
web/package.json | 3 +-
web/server.js | 14 +++++
web/src/auth/auth.js | 0
web/src/blog/board.js | 7 +++
web/src/blog/comment.js | 0
임시로 저장(백업) 된 내용을 불러옵니다.
[stephen@fedora web]$ git stash pop
Auto-merging web/package-lock.json
Auto-merging web/package.json
Auto-merging web/server.js
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
modified: server.js
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (913308170600e8684e4c1f9848776121afe70ef9)
이후, git에 대하여 나머지 작업을 진행하면 됩니다.
'Linux & Development' 카테고리의 다른 글
nodejs version 업그레이드 (1) | 2024.06.15 |
---|---|
Linux chrony client 설정 (0) | 2024.04.18 |
OpenSSL을 이용한 SSL 인증서 발급 방법 (0) | 2024.04.09 |
Linux TuneD 이용한 성능 최적화 (0) | 2024.04.04 |
Network Bonding - Rocky/CentOS/RHEL (0) | 2024.04.01 |