Git 기초 정리

Yzzang·2023년 12월 18일
0

[git]

목록 보기
1/12

Git
Working directory(내 작업공간)-staging area(add하면 나오는 저장소)-repotsitory(git 커밋 저장소)

commit에 관한 주의사항

  1. 처음으로 커밋하기 전 사용자 이름과 이메일 주소 설정
    git config user.name “이름”
    git config user.email “이메일”

  2. 커밋 메시지 남기기(옵션-m)
    Git commit -m “ 내용“

  3. 커밋할 파일 git add로 지정해주기
    git add 파일명

Git 설정 확인

git config --list
git config -l

계정 설정

--global를 사용하여 전역으로 설정
git config --global user.name "USER_NAME"
git config --global user.email "USER_EMAIL"

Repository마다 다른 사용자(계정) 정보 사용
git config --local user.name "USER_NAME"
git config --local user.email "USER_EMAIL"

설정된 user.name, user.email이 있을 때, 삭제 후 설정 진행
설정된 계정 삭제

global

git config --unset --global user.name
git config --unset --global user.email

local

git config --unset user.name
git config --unset user.email

staging area에 상태 확인하기!!

git status

변경사항이 있는 모든 파일 한번에 add 하기

git add.

git add 취소(staging area에서 파일 제거)

git reset 파일명

요약

  • git init : 현재 디렉토리를 Git이 관리하는 프로젝트 디렉토리(=working directory)로 설정하고 그 안에 레포지토리(.git 디렉토리) 생성
  • git config user.name 'xxx' : 현재 사용자의 아이디를 'xxx'으로 설정(커밋할 때 필요한 정보)
  • git config user.email 'xxxxx' : 현재 사용자의 이메일 주소를 'xxxxx'로 설정(커밋할 때 필요한 정보)
  • git add [파일 이름] : 수정사항이 있는 특정 파일을 staging area에 올리기
  • git add [디렉토리명] : 해당 디렉토리 내에서 수정사항이 있는 모든 파일들을 staging area에 올리기
  • git add . : working directory 내의 수정사항이 있는 모든 파일들을 staging area에 올리기
  • git reset [파일 이름] : staging area에 올렸던 파일 다시 내리기
  • git status : Git이 현재 인식하고 있는 프로젝트 관련 내용들 출력(문제 상황이 발생했을 때 현재 상태를 파악하기 위해 활용하면 좋음)
  • git commit -m "커밋 메시지" : 현재 staging area에 있는 것들 커밋으로 남기기
  • git help [커맨드 이름] : 사용법이 궁금한 Git 커맨드의 공식 메뉴얼 내용 출력
profile
미래개발자

0개의 댓글

관련 채용 정보