잡다 정보

git 명령어

김상주 2023. 5. 15. 15:24

로컬 브랜치 삭제

git branch -d 브랜치명

충돌시에 대문자로 하면 강제 삭제

원격 브랜치 삭제

git push origin --delete 브랜치명

 

원격 레포에서 로컬로 클론해오기

$ git clone {주소}


기존의 코드에서 pull하기

$ cd KJ2R-W05-07
$ git checkout main
$ git pull

로컬에서 원격 레포로 푸시하기

$ cd Week07                              # Week07 dir로 이동
$ mkdir ${제출자ID}                      # 제출자 전용 dir 생성
$ cd ${제출자ID}
$ git checkout -b week07/${제출자ID}     # 제출자 전용 branch 생성
$ git push -u origin week07/${제출자ID}  # git push를 위한 사전 작업

$ git add .
$ git commit -m 'feat: add results'
$ git push

 

원격 레포 바꾸기

 git remote set-url origin <변경할 원격 저장소 주소>

처음 깃에 연결할때

$ git init
$ git remote add origin (GitHub주소)  //origin이라는 이름으로 추가한다면 이렇게 하시면 됩니다!

특정 레포에서 클론해오기

  • $ git clone -b <branch명> <remote_repo 주소>

 

깃 캐시삭제

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

pull commit 오류떄

명령어 git reset --soft HEAD^