Git

간단하게 git bash 를 통해 최초 설정 및 레퍼지토리 생성 후 올리기

smyoon 2024. 3. 4. 15:21

 

Git 최초 설정

1. 사용자 설정 및 확인

git config --global user.name "username"
git config --global user.email "username@gmail.com"

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

 

2. 기본 브랜치 명 변경

git config --global init.defaultBranch main
git config --global init.defaultBranch

 

 

 

 

Git 프로젝트(repository) 생성 

1. 현재 디렉토리 기준 git 저장소 생성

git init

 

2. 로컬 저장소에 연결

git remote add origin https://github.com/[본인계정명]/[디렉토리명]

 

3. 파일 상태 확인

git status

 

4. 파일 추가

# 모든 파일 담기
$ git add .         

# 해당 파일 담기
$ git add [파일명]

 

5. 해당 파일 commit

# vi 입력모드로 진입하여 메시지 작성
git commit

# 커밋 메시지까지 한 번에 작성 
git commit -m "comment"

 

5. 레퍼지토리랑 파일 연결

git remote add origin [해당 깃 주소]

 

6. 레퍼지토리에 파일 올리기

git push origin master[main]

 

 

 

 

 

 

[참고]

https://gin-girin-grim.tistory.com/10

https://eunhee-programming.tistory.com/158