GitLab

GIT push

2022. 6. 21. 22:04
반응형

push

local repository에 commit 이력을 remote branch 로 보낼 경우 사용

git push origin {branch}
git push origin {branch} -f  // remote force push

최근 commit 이력을 취소하고 push(remote에 잘못된 commit 이력을 push 했을 경우)

git reset HEAD^ 
git push origin master -f

commit history 전부 삭제하고 초기 상태로 되돌릴 경우

rm -rf .git 
git init 
git add . 
git commit -m "feat(init): initial commit" 
git push origin master
반응형

'Infra > git' 카테고리의 다른 글

GIT merge  (0) 2022.06.21
GIT rebase  (0) 2022.06.21
GIT commit  (0) 2022.06.21
GIT stash  (0) 2022.06.21
GIT clean  (0) 2022.06.21

GIT commit

2022. 6. 21. 22:02
반응형

commit

  • 작업 중인 파일 내역 저장 (원격 저장소 push 전 수행)
  • 작업시 기능 단위로 나눠서 #commit 하면 코드 리뷰 시 리뷰어가 보기 편함
git commit -m "commit init"
git commit --amend  //message vi 모드
git commit --amend -m "메세지 변경"  //message 변경
git reset HEAD^ or git reset {commit id} //local commit 취소
git commit --allow-empty -m "empty commit"  //empty commit
반응형

'Infra > git' 카테고리의 다른 글

GIT rebase  (0) 2022.06.21
GIT push  (0) 2022.06.21
GIT stash  (0) 2022.06.21
GIT clean  (0) 2022.06.21
GIT restore  (0) 2022.06.21

GIT stash

2022. 6. 21. 22:00
반응형

stash

  • workspace에서 수정 중인 파일 임시 저장
  • 작업 중 #브랜치 전환할 경우 수정 중인 파일 임시로 저장 후 스위칭시 유용함
git stash save {stashname}
git stash list  //목록 보기
git stash clear  // 전체 삭제
git stash apply stash@{0}  //저장된 stash 불러오기
git stash pop  //가장 마지막에 save한 stash 불러오기
반응형

'Infra > git' 카테고리의 다른 글

GIT push  (0) 2022.06.21
GIT commit  (0) 2022.06.21
GIT clean  (0) 2022.06.21
GIT restore  (0) 2022.06.21
GIT add  (0) 2022.06.21

GIT add

2022. 6. 21. 21:55
반응형

add (staged area)

  • 수정한 파일을 unstaged -> staged 로 이동 (commit 전 실행)
git add --all or add . or add {filename}
git reset HEAD {filename} or 파일명 없을 경우 전체 //staged -> unstaged
반응형

'Infra > git' 카테고리의 다른 글

GIT clean  (0) 2022.06.21
GIT restore  (0) 2022.06.21
GIT cherry-pick  (0) 2022.06.21
GIT checkout  (0) 2022.06.21
GIT remote  (0) 2022.06.21

GIT cherry-pick

2022. 6. 21. 11:37
반응형

cherry-pick

  • 다른 브랜치 commit hash 가져오기
git cherry-pick {5775401d}
git cherry-pick f2abff5^..8e2fa35  //범위 지정하여 가져오기 (f2abff5~ 8e2fa35 commit 까지)

 

반응형

'Infra > git' 카테고리의 다른 글

GIT restore  (0) 2022.06.21
GIT add  (0) 2022.06.21
GIT checkout  (0) 2022.06.21
GIT remote  (0) 2022.06.21
GIT status  (0) 2022.06.21

+ Recent posts

반응형