Remote 저장소
기존 워킹 디렉토리에 새 remote 저장소를 추가할 때는, git remote add <단축이름> <저장소 url> 명령을 사용한다 이제 url 대신 <단축이름> 을 사용할 수 있다
git remote add apollo <저장소 url>
최초 연동할 때 git remote add origin <저장소 url> 로 많이 사용한다
git remote add origin https://github.com/xxxxidxxx/xxxrepoxxx.git
git remote 로 현재 프로젝트에 등록된 remote 저장소를 확인할 수 있다. remote 저장소의 단축 이름만 보여준다
저장소를 add origin 했으면, origin 이 있다. 저장소를 clone 해왔어도 origin 이 자동으로 등록돼 있다
git remote
/* origin */
-v 옵션을 주면 단축이름과 url 을 함께 볼 수 있는 것이다
git remote -v
// origin https://github.com/xxxxidxxx/xxxrepoxxx.git (fetch)
// origin https://github.com/xxxxidxxx/xxxrepoxxx.git (push)
remote 저장소에서 pull 땡겨 오려면 다음과 같이 git pull origin <브랜치 이름>
/* git pull origin master / git pull origin main */
/* git pull apollo master / git pull apollo main */
프로젝트를 공유하고 싶을 때 Upstream 저장소에 push 할 수 있다. 명령은 git push <remote 저장소 단축이름> <브랜치 이름> 이다. 직접 master / main 브랜치, default 브랜치를 `origin 서버`에 push 할 수도 있다
git push origin master
git push origin main
git push origin develop
위 명령은 (clone 한) remote 저장소에 쓰기 권한이 있고, 그 후 아무도 Upstream 저장소에 push 하지 않은 경우에 사용할 수 있다. 먼저 다른 사람이 작업한 것을 가져와서 Merge 한 후에만 Push 할 수 있다. (내용 참고)
remote 저장소에 만든 branch 에 push 한다. 그러면 default 브랜치에 Pull Request 가 뜨니까 거기서 PR 생성하거나, 안 떠도 탭에서 선택해서 생성한다.
git push origin <작업한 브랜치명>
git push origin feat/1
Pull Request 보낼 때는 Squash and merge 로 바꿔서 모든 commit 을 하나로 뭉친 후 Merge 시키는 게 보기 좋다
참고