로컬 프로젝트랑 원격 폴더랑 연결하기

이유정·2024년 1월 8일
0

정리하는 이유는?
오랜만에 프로젝트 시작할 때마다 조금 헤매는 시간들이 생겨서 이참에 ~~ 정리할고 한다.
내 컴퓨터에 프로젝트를 생성했고, 깃허브에도 폴더를 생성한 상황에서
연결하는 방법을 정리해보았다. !

깃허브의 첫번째 항목을 따라가면 된다.

현재 내가 바탕화면에 생성한 프로젝트 에서 어떻게 깃허브랑 연결하나?

# 로컬 프로젝트 폴더로 이동
cd ~/Desktop/프로젝트폴더명

# 깃 저장소 초기화
git init

# 모든 파일 스테이징 및 커밋
git add .
git commit -m "Initial commit"

# 깃허브 저장소와 로컬 프로젝트 연결
git remote add origin https://github.com/FordangIT/새로운저장소이름.git

# 깃허브로 푸시
git push -u origin main

내가 성공한 코드

git init

git add .

git commit -m "chore: 기본 설치"

git remote add origin https://github.com/FordangIT/artgarden.git

git branch -a //그냥 확인하는 코드 
* master

git push -u origin main //에러가 난다. 
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/FordangIT/artgarden.git'

git branch -M main //이것부터 해줘야 하거든. 

git branch -a //아직 원격이 보이지 않는다. 
* main

git push origin main //push까지 해야 원격이 보일 것 ! 

Enumerating objects: 23, done.
Counting objects: 100% (23/23), done.
Delta compression using up to 8 threads
Compressing objects: 100% (20/20), done.
Writing objects: 100% (23/23), 56.23 KiB | 3.12 MiB/s, done.
Total 23 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/FordangIT/artgarden.git
 * [new branch]      main -> main
profile
강의 기록 블로그

0개의 댓글

관련 채용 정보