$ git init
$ git remote add origin [원격저장주소]
$ git push -u orgin master
$ git pull (또는 git pull origin [브랜치 이름])
$ git add .
$ git commit -m "commit message"
$ git push (또는 git push origin [브랜치 이름])
깃허브에 원격저장소를 만들기
깃허브 페이지의 repository를 만들면 됨(자세한건 생략하겠음)
내 컴퓨터에(=올리려는 파일이 있는 폴더)에 로컬 저장소를 만들기
[참고] 폴더와 같이 올리려면 해당 폴더의 외부 폴더에서 git init을 해줘야 함
그 둘을 연결 해서 로컬 저장소의 파일을 원격 저장소로 보내라고 명령하기
git init
폴더 안에 .git이라는 폴더가 생성이 됨
$ git remote add origin [원격저장주소]

git add . #전체 파일 업로드
git add [파일명 혹은 파일디렉토리]
git commit -m "커밋메세지"
git push -u orgin main #main외에 다른 브랜치명 적어도됨
-u : --set-upstream 의 약자로, 현재 로컬브랜치와 원격 브랜치의 연결을 함
로컬 브랜치(main)과 원격브랜치(origin/main)이 연동됨
초기에는 이렇게 설정해줘야 트래킹 정보 설정이 되어 나중에 git push, git pull만 하여도 됨
! [rejected] main -> main (non-fast-forward)
#--set-upstream과 브랜치명 앞에 +붙여주기
git push --set-upstream origin +main
error: failed to push some refs to 'origin'
# 로컬저장소에 없는 파일이 원격저장소에 있을 때 로컬 -> 리모트 push가 안됨
# 원격저장소 먼저 pull하고 push하기
git pull origin main
error: failed to push some refs to 'https://github.com/gcpower/project.git'
#로컬 저장소에 커밋된 파일이 없는 경우
git status
git add * #**git add .**과 같지만 .gitignore 파일도 다 올려지게 됨
git commit -m "커밋메세지"
빈 폴더에 원하는 원격저장소의 내용 주소를 가져와서 git clone해주기
git clone [원격저장주소]
기존에 작성했던 코드 및 파일이 있다면 그 폴더 내에 넣기
커밋 및 Pull Requst하기
git add . #전체 파일 업로드
git add [파일명 혹은 파일디렉토리]
git commit -m "커밋메세지"
git push -u origin main #main외에 다른 브랜치명 적어도됨
fatal: unable to access
리포지토리 설정에 들어가서 collaborators에 사용자 추가하기
origin/main branch에 아무것도 없는 경우에 git branch 브랜치명을 통해 바로 분기가 안되는 이유