로메오의 블로그

git 리모트 연결 & 리모트 url 변경 본문

Frontend/ETC

git 리모트 연결 & 리모트 url 변경

romeoh 2023. 1. 25. 15:37
반응형

로컬 저장소와 원격 저장소 연결하기

## 로컬 레파지토리 생성
$ git init project
$ cd project

## 파일 생성 커밋
$ echo "hello" > new.txt
$ git add new.txt
$ git commit -m "first commit"

## 원격 레파지토리 확인
$ git remote -v

## 원격 레파지토리 연결
$ git remote add origin https://ID@bitbucket.org/ID/project.git

## 원격 레파지토리 확인
$ git remote -v
master  https://ID@bitbucket.org/ID/project.git (fetch)
master  https://ID@bitbucket.org/ID/project.git (push)

## git pull
$ git pull origin master --allow-unrelated-histories
From https://bitbucket.org/romeoh/project
 * branch            master     -> FETCH_HEAD
Merge made by the 'ort' strategy.
 .gitignore | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 .gitignore

## push 
$ git push -u origin master 
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 498 bytes | 166.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To https://bitbucket.org/ID/project.git
   ae12789..818c222  master -> master
branch 'master' set up to track 'origin/master'.

 

 

 

원격 레파지토리 변경하기

## 원격 레파지토리 확인
$ git remote -v
origin  https://ID@bitbucket.org/ID/project.git (fetch)
origin  https://ID@bitbucket.org/ID/project.git (push)

## 원격 레파지토리 삭제
$ git remote remote origin

## 다른 원격 레파지토리 추가
$ git remote add origin https://ID@bitbucket.org/ID/project2.git

## 원격 레파지토리 확인
$ git remote -v
origin  https://ID@bitbucket.org/ID/project2.git (fetch)
origin  https://ID@bitbucket.org/ID/project2.git (push)

## git pull
$ git pull origin master --allow-unrelated-histories
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 585 bytes | 97.00 KiB/s, done.
From https://bitbucket.org/romeoh/project2
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
Merge made by the 'ort' strategy.


## push
$ git push -u origin master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 841 bytes | 420.00 KiB/s, done.
Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
To https://bitbucket.org/ID/project2.git
   14dd07f..837aaed  master -> master
branch 'master' set up to track 'origin/master'.

 

vim 에디터 저장/종료

esc + :wq

반응형

'Frontend > ETC' 카테고리의 다른 글

크롬 확장 프로그램  (0) 2023.05.26
CryptoJS 암호화  (0) 2023.03.24
유튜브 인사이트 평균  (0) 2022.08.26
SourceTree 비밀번호 저장 이슈 - Mac  (0) 2022.08.23
[Array Method] push, pop, unshift, shift...  (0) 2022.04.26
Comments