[git] git reset

devJun's avatar
Aug 06, 2024
[git] git reset
 
💡
현재 HEAD 의 포인트를 변경해 기록을 수정하거나, 특정 파일로 되돌릴 수 있음
notion image
 
git soft :commit log 변경시 사용 git mixed : 작업 영역의 내용 변경시 사용 git hard : 이전 단계로 변경시 사용
 
 
notion image
 
 
 
[test reset1] public class Reset { public static void main(String[] args) { System.out.println("1"); } }
 
[test reset2] public class Reset { public static void main(String[] args) { System.out.println("1"); System.out.println("2"); System.out.println("3"); } }
notion image
 
두번의 commit 을 했다.
 
 

1. git soft

git reset --soft 해시값
notion image
notion image
notion image
 
HEAD 가 test reset2 에서 reset1 으로 변경되었다.

2. git mixed

git reset 해시값
notion image
notion image
 
 

3. git hard

git reset --hard 해시값
notion image
 
notion image
notion image
 
hard 를 사용하면 commit 이전으로 돌아간다.
 
Share article

devJun