Git 기본 명령어

@donghoonyeom · June 27, 2023 · 2 min read

1

Git 저장소 생성

$ git init

기본 브랜치 이름 변경

$ git config --global init.defaultBranch 변경할_브랜치_이름

현재 상태 확인

$ git status

전체 로그 확인

$ git log

Staging area로 파일 이동시키기

$ git add .

저장소 복제 및 다운로드

$ git clone https://github.com/{GITHUB_NAME}/{REPOSITORY_NAME}.git

파일을 Local repository에 저장하고 버전을 기록(commit)

$ git commit -m "message"

Remote repository로 업로드

$ git push origin master

원격 저장소의 변경 내용을 현재 디렉토리로 가져오기 (pull)

$ git pull

Remote repository와 Local repository를 연결

$ git remote --v

브랜치 삭제

$ git branch -d [브랜치명]

현재 브랜치에 다른 브랜치 수정사항 병합

$ git merge [다른 브랜치명]

복사할 코드가 있는 Rmote Repository의 코드를 내 Rmote Repository로 복사

$ Fork

상대의 Rmote Repository 주소를 내 Local Repository와 연결

$ git rmote add pair [상대의 Rmote Repository 주소]

연결된 주소들의 목록 확인

$ git rmote -v

파일 수정

$ nano [파일이름]

수정한 파일을 staging area에 추가 (commit 전)

$ git add [파일이름]

commit이 되지 않은 파일을 폐기

$ git restore [파일이름]

staged된 파일을 이전 상태로 되돌림

$ git restore --staged
@donghoonyeom
꾸준히, 의미있는 학습을 기록하기 위한 공간입니다.