git init
git add *.py # 해당 Directory에 있는 py파일을 전부 add
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/[github 이름]/[github repo 이름]
git push origin main
- git init : .git이라는 하위 디렉토리를 만든다. .git파일은 저장소에 필요한 뼈대 파일이 있다.
- Git이 파일을 관리하게 하려면 저장소에 파일을 추가(git add)하고 커밋(git commit)해야한다.
- git add은 staged에 올리고, commit은 Local repo에 올리는 명령어
- git remote : git의 Local repo와 Remote repository(github)에 연결하기 위해 실행한다.
- git push : Local repo에서 Remote repo로 파일을 업로드 명령어 이다.
Directory 내에 Tracked(관리대상) , UnTracked(비 관리대상)으로 나뉜다.
Tracked : Unmodified, Modified , Staged
git add [파일명]을 하면 파일은 staged 상태로 들어간다.
git status를 실행하면, Changes to be committed 에 들어 있는 Staged상태의 파일이라는 것을 확인 할 수 있다.
git status
git status -s # git status --short
# 위 명령어는 status를 간단하게 보여주는 옵션이다.
# 새파일 앞에는 ?? , Staged상태로 추가한 파일은 A
# 수정한 파일 앞에는 M
예시)
'git 사용법' 카테고리의 다른 글
Git-Github 사용법 - 1) 초기 세팅(git config) 및 수정 (0) | 2023.01.23 |
---|