반응형

Git 8

[Git] 실수로 git push한 내역 안전하게 되돌리기

안녕하세요.이번 시간에는 실수로 git push를 잘못하였을 경우,이를 안전하게 되돌리는 방법에 대하여 살펴보도록 하겠습니다. 상황 가정만일, 다음과 같이 main 브랜치에 git push를 실수로 했던 상황을 가정해보겠습니다.git reset --hard 1bd654f # 커밋 번호 가정git push origin main --force이럴 때에 "내가 작업한 커밋들이 전부 사라진 건 아닐까?" 하는 생각에 당황하기 쉽습니다.하지만 git은 로컬 기록을 잘 관리하고 있어 침착하게 복구할 수 있습니다. 복구 방법다음 명령어로 내역을 조회할 수 있습니다.git reflog 그러면 다음과 같이 내역이 시간 순으로 출력되는데, 잘못 push한 내역의 이전을 기준으로되돌리고 싶은 커밋 해시 번호를 찾아주시면..

Git 2025.07.13

[Git] 파이썬 프로젝트에 대하여 pre-commit 적용 방법 예시

안녕하세요. 이번 시간에는 코드 커밋 이전에 자동으로 포맷팅, 린팅, 문법 검사 등을 수행하면서일관된 코드 스타일을 유지하고, CI 파이프라인 전단계에서 실수를 잡아낼 수 있도록pre-commit 프레임워크를 적용하는 방법을 예시를 통해서 간단하게 살펴보도록 하겠습니다. 해당 글에서는 파이썬 프로젝트 레포를 기준으로 설명을 진행하겠습니다. 1. 설정 파일 작성 예시원하는 커밋 훅 종류를 골라 다음과 같이 레포 내 루트 디렉토리에 .pre-commit-config.yaml이름의 파일로 작성해줍니다.fail_fast: falserepos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: tr..

Git 2025.06.14

[Git] warning: adding embedded git repository 원인 및 해결법

개요git 사용 과정에서 다음과 같은 경고 메시지가 발생하였습니다.warning: adding embedded git repository: frontendhint: You've added another git repository inside your current repository.hint: Clones of the outer repository will not contain the contents ofhint: the embedded repository and will not know how to obtain it.hint: If you meant to add a submodule, use:hint:hint: git submodule add frontendhint:hint: If you adde..

Git 2024.10.22

[Git] git pull 시 fatal: refusing to merge unrelated histories 오류 원인 및 해결 방법

git pull 과정에서 fatal: refusing to merge unrelated histories 라는 메시지가 출력되며동기화에 실패하는 경우, 원인과 해결책에 대하여 간략하게 정리해보도록 하겠습니다.  개요git pull 과정에서 다음과 같은 오류 메시지가 발생하며,동기화에 실패하고 있습니다.########################### W A R N I N G ############################This equipment is privately owned.All access to this equipment is logged.Disconnect IMMEDIATELY, if you are not an authorized userViolators will be prosecuted ..

Git 2024.10.08

[Git] fatal: couldn't find remote ref ~~ fatal: the remote end hung up unexpectedly 원인 / 해결 방법

개요 git pull 과정에서 다음과 같은 형태의 오류 메시지가 발생하며, pull 진행이 불가능 하였습니다. ########################### W A R N I N G ############################ This equipment is privately owned. All access to this equipment is logged. Disconnect IMMEDIATELY, if you are not an authorized user Violators will be prosecuted to the fullest extent of the law. #####################################################################..

Git 2024.02.19

[Git] git config pull.~~ warning 시 해결 방법, pull config 차이 예시

git pull 과정에서 config를 설정해야 하는 상황으로 pull이 안되는 경우 이를 해결하는 방법과 각 config에 따른 차이를 예시로 간략하게 정리해보도록 하겠습니다. 개요 git pull 과정에서 다음과 같은 warning 메시지가 발생하며, pull이 안되는 경우가 있습니다. ########################### W A R N I N G ############################ ~~~ ###################################################################### ~~~ From git.projectbro.com:project_name/repo_name * branch main -> FETCH_HEAD abcdef..gh..

Git 2024.01.29

[Git] ! [rejected] main -> main (fetch first)error: failed to push some refs... 원인 및 해결 방법

git push 과정에서 conflict로 인하여 자주 발생할 수 있는 오류 메시지에 대하여 원인과 대처 방법을 간략히 정리해보도록 하겠습니다. 에러 개요 git push를 하는 과정에서 다음과 같은 오류 메시지가 발생하면서, push가 거절당했습니다.(브랜치 이름이 main인 경우를 기준으로 가정합니다.) To git.projectbro.com:project_name/repo_name ! [rejected] main -> main (fetch first) error: failed to push some refs to 'git.projectbro.com:project_name/repo_name' hint: Updates were rejected because the remote contains work ..

Git 2024.01.28

[Git] error: object file ~ is empty / error: remote unpack failed: eof before pack header was fully read 해결법

오류 개요 작업 중 컴퓨터가 비정상적으로 재부팅된 후, Git에서 push를 하는 도중에 다음과 같은 오류 메시지가 발생하였습니다. error: object file .git/objects/41/abcdef is empty error: object file .git/objects/b6/ghijkl is empty Counting objects: 100% (17/17), done. Delta compression using up to 16 threads Compressing objects: 100% (7/7), done. error: object file .git/objects/41/abcdef is empty fatal: loose object mnopqr (stored in .git/objects/41..

Git 2024.01.23
반응형