2021년 4월 21일 수요일

git rebase 사용법(commit 삭제)

 1. git rebase -i HEAD ~ (원하는 숫자)


그러면 해당하는 커밋들과 함께 vi 창이 나온다 (숫자 맞지 않으면 에러~)




pick 7e298ab 도면정보 시스템 중간정도 완성
pick f89f914 버닝  세이더 삭제 한거 이름 변경함

# Rebase c84faf8..f89f914 onto c84faf8 (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everythingthe rebase will be aborted.
#

이런식으로 명령어들과 함께 현재 수정할 커밋들이 나온다



예를들어 이름을 바꾸고 싶으면

pick 7e298ab 도면정보 시스템 중간정도 완성
pick f89f914 버닝  세이더 삭제 한거 이름 변경함

에서

pick 7e298ab 도면정보 시스템 중간정도 완성
r f89f914 버닝  세이더 삭제 한거 이름 변경함

이런식으로 변경하고 :wq를 실행하면 새로운 해당하는 vi창이 새로 열린다

(수정은 i를 누르고 원하는곳을 변경하면 됨)




열린 vi는 다음과 같다

버닝  세이더 삭제 한거 이름 변경함

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Thu Apr 22 15:16:37 2021 +0900
#
# interactive rebase in progress; onto c84faf8
# Last commands done (2 commands done):
#    pick 7e298ab 도면정보 시스템 중간정도 완성
#    reword f89f914 버닝  세이더 삭제 한거 이름 변경함
# No commands remaining.
# You are currently editing a commit while rebasing branch 'master' on 'c84faf8'.
#
# Changes to be committed:
#       deleted:    Assets/BurningShader/Assets.meta
#       deleted:    Assets/BurningShader/Assets/Audio.meta
#       deleted:    Assets/BurningShader/Assets/Audio/sfx_Burning.wav
#       deleted:    Assets/BurningShader/Assets/Audio/sfx_Burning.wav.meta
#       deleted:    Assets/BurningShader/Assets/Materials.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_01_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_01_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_02_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_02_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_03_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_03_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_04_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_build_storage_04_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_logpile_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_logpile_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_plank_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_plank_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_wall_logs_met.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/Metallic/mat_wall_logs_met.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_Burn_Slab.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_Burn_Slab.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_01.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_01.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_02.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_02.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_03.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_03.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_04.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_build_storage_04.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_logpile.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_logpile.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_plank.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_plank.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_wall_logs.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Buildings/mat_wall_logs.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Particles.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Particles/mat_embers.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Particles/mat_embers.mat.meta
#       deleted:    Assets/BurningShader/Assets/Materials/Particles/mat_fire.mat
#       deleted:    Assets/BurningShader/Assets/Materials/Particles/mat_fire.mat.meta


이 부분에서 이름을 변경하고 :wq로 저장하면 완료!



삭제하는 동시에 파일도 최신 master 커밋으로 돌아옴!





댓글 없음:

댓글 쓰기

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...