git

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 clean

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

clean

  • untracked file 삭제해야 할 경우
git clean -f // untracked file
git clean -d // untracked folder
git clean -fd // file 및 folder 까지
반응형

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

GIT commit  (0) 2022.06.21
GIT stash  (0) 2022.06.21
GIT restore  (0) 2022.06.21
GIT add  (0) 2022.06.21
GIT cherry-pick  (0) 2022.06.21

GIT restore

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

restore

  • commit 전 unstatged에 존재하지 않는 수정된 파일을 HEAD revision 으로 되돌림
git restore {filename}
반응형

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

GIT stash  (0) 2022.06.21
GIT clean  (0) 2022.06.21
GIT add  (0) 2022.06.21
GIT cherry-pick  (0) 2022.06.21
GIT checkout  (0) 2022.06.21

+ Recent posts

반응형