Etc

Git

배고픈 징징이 ㅣ 2023. 1. 20. 09:47

1.  commit 취소

//^~1은 최근 한건을 선택하는 조건
git reset HEAD^~1

 

2. merge 취소

git reset --merge ORIG_HEAD

 

3. push 취소

//1. HEAD를 커밋ID부분으로 강제변경
//git reset --hard [커밋ID]
git reset --hard 38379b23

//1.5. 혹시나 커밋이 안되어있는 상황이 생길지 모르니... 커밋하는법
//git commit -m "코맨트"

//2. 커밋은 이미되어있으니 강제 푸쉬
git push origin master -f

 

4. 사용자 이름 변경

git config user.name "{userName}"

 

5. cherry pick

//Git에서 master에 모든 commit이 아닌 특정 하나의 commit만 merge 시키고 싶을때
git cherry-pick 34f7544e(log에서 보이는 git commit id를 넣어준다)

 

6. Git ignore 반영

git rm -r --cached .
git add .

git commit -m "commit message”

 

7. Git에 잘못 올라간 폴더 삭제

//--cached가 없으면 로컬 폴더까지 삭제
git rm --cached -r 경로

git commit -m "commit message"

 

8. Git reset --hard로 지워진 커밋 복구

//커밋내역에는 없지만 git에 보관되고 있는 이력 확인
git reflog

//그중에 특정 브랜치 필터링
//git reflog show [branch]
git reflog show feature/kht

//해당 커밋으로 강제 변경
//git reset --hard [commit id]
git reset --hard 5920cb8

 

9. Git 삭제된 브랜치가 개발툴에서 계속 보일때 

git remote prune origin
반응형

'Etc' 카테고리의 다른 글

WebRTC  (0) 2024.07.30
CQRS (Command and Query Responsibility Segregation)  (0) 2024.02.26
Window Fpp 인증 해제 및 신규 인증  (0) 2023.04.05
Maven Phase & Scope & Copy Dependencies  (0) 2023.02.09
Rest API 참고  (0) 2023.01.19