무소의 뿔처럼

git bash 명령문 본문

알아두기

git bash 명령문

값을변경 2023. 1. 20. 11:19

처음

git init
git add .
git commit -m "커밋 메세지를 적으세요"
git remote add origin https://github.com/test/test.git
git push --set-upstream origin main

 

확인

git status
git remote -v
git ls-remote
git log

 


reset  (options : soft | mixed | hard )

예를 들어
1번 파일 hash : eifi2 ...
2번 파일 hash : fl5ik ...  일때,

 

//hash값 앞에 5글자 정도? 겹치지만 않으면 알아서 찾음.

git reset --soft eifi2  //<-돌아갈 형상의 해쉬값

 soft는 보통 바로 직전의 커밋로그 변경 시 쓰임. : ~ branch 버림.

 

git reset --mixed eifi2

mixed는 보통 작업영역의 내용변경 시 쓰임 : ~ 인덱스 영역 까지 버림. 

git status 에서 보면 변경만 감지한 상태로 돌아온다.

 

git reset --hard eifi2

hard는 eifi2의 해쉬값이 있는 파일만 있을 때로 돌아감. :~ eifi2 이후에 만든 파일까지 버림.

 

git log

log 확인 하기.

 

 

amend

이 전 로그가 없을때... 수정해야 한다면? ㅠ // 최종 로그 변경!

git commit --amend -m "커밋메세지"

 

 


reflog

엄청난 back-up의 date! 한번이라도 commit 했으면 log가 남는다.

git reflog

reflog에서 확인 후, 돌아갈 commit log에서 hash값을 적는다.

git reset --hard ofjwoi2

git log를 확인하면 돌아간 것을 볼 수 있다. 

 


clear

 

저장소

git push origin main
git pull origin main
git remote rm origin //저장소 연결 삭제
#git init + git remote + git pull
git clone https://github.com/test/test.git
#모두 같음.

git checkout -b branch1
git fetch origin
git merge origin/branch1

git checkout -b branch1
git pull origin branch1

git fetch origin
git checkout -b branch1 origin/branch1

 

*인프런 무료 강의 : 지옥에서 온 관리자 Git

 

 

'알아두기' 카테고리의 다른 글

tomcat 8.0.53 다운로드  (0) 2023.02.23
환경) 이클립스 tern  (0) 2022.12.30
Git ) import 순서 기억하기  (0) 2022.09.02
Comments