컴퓨터 프로그래밍/Git

[Git] Remote Repository 등록 및 변경

한33 2024. 10. 13. 21:50

1. Repository 생성

 

2. IntelliJ 파일 생성

 

3. git bash 터미널에 아래 코드 입력

 

echo "# e" >> README.md
git init
git add README.md
git commit -m "{commit 하고 싶은 문구}"
git branch -M main
git remote add origin {remote 하고 싶은 Repository 주소}
git push -u origin main

 

4. Remote 및 commit, push 성공!


Remote 를 이용해서 Repository 를 변경하면, Repository 를 다른 Repository 에도 적용시킴으로서,

backup 파일을 만들다든지, 반복되는 작업을 Repository 를 통해서 해결하고 시작할 수도 있다.


현재 원격 저장소 확인

git remote -v

 

현재 원격 저장소 제거

git remote remove <원격 저장소 이름 ( 보통 origin )> 

 

새로운 원격 저장소 추가

git remote add origin <새로운 레포지토리 URL>

 

원하는 브랜치 푸시

git push origin main