지점이 추적하는 원격을 변경하는 방법은 무엇입니까?
central
저장소 내 지역의 repo에 새 원격을 생성하므로, 새 서버에 설정하고 그에게 밀어했다.
그러나 지금 내가 할 때 git pull
, 그것은 내가 최신 상태라고 주장합니다. 그것은 잘못된 것입니다. 그것은 새로운 것이 아니라 이전 원격 브랜치 에 대해 말하고 있습니다 . 사실 새로운 커밋을 가져올 수 있다는 것을 알고 있습니다.
다른 리모컨을 추적하기 위해 로컬 브랜치를 어떻게 변경합니까?
git 구성 파일에서 이것을 볼 수 있지만 엉망으로 만들고 싶지 않습니다.
[branch "master"]
remote = oldserver
merge = refs/heads/master
git v1.8.0 이상 사용 :
git branch branch_name
--set-upstream-to
your_new_remote/branch_name
또는 -u
스위치를 사용할 수 있습니다 .
git branch branch_name
-u
your_new_remote/branch_name
git v1.7.12 이하 사용 :
git branch --set-upstream branch_name your_new_remote/branch_name
나를 위해 수정 사항은 다음과 같습니다.
git remote set-url origin https://some_url/some_repo
그때:
git push
최신 git (2.5.5)의 명령은 다음과 같습니다.
git branch --set-upstream-to=origin/branch
현재 로컬 브랜치의 원격 추적 브랜치를 업데이트합니다.
일어나는 일을 많이 제어 할 수있는 또 다른 옵션은 구성을 직접 편집하는 것입니다.
git config --edit
또는 속기
git config -e
그런 다음 원하는대로 파일을 편집하고 저장하면 수정 사항이 적용됩니다.
제정신이라면 구성 파일을 편집하는 것이 충분히 안전합니다. 좀 더 편집증이되고 싶다면 porcelain 명령을 사용하여 수정할 수 있습니다.
git config branch.master.remote newserver
물론 이전과 이후의 구성을 살펴보면 수행하려는 작업이 정확히 수행되었음을 알 수 있습니다.
그러나 귀하의 개인적인 경우에는 다음과 같습니다.
git remote rename origin old-origin
git remote rename new-origin origin
즉, 새 서버가 표준 원격이 될 경우 원래 복제 된 것처럼 원본이라고 부르는 것이 어떻습니까?
git fetch origin
git checkout --track -b local_branch_name origin/branch_name
또는
git fetch
git checkout -b local_branch_name origin/branch_name
이것은 가장 쉬운 명령입니다.
git push --set-upstream <new-origin> <branch-to-track>
예를 들어 git remote -v
다음과 같은 명령이 생성됩니다.
origin ssh://git@bitbucket.some.corp/~myself/projectr.git (fetch)
origin ssh://git@bitbucket.some.corp/~myself/projectr.git (push)
team ssh://git@bitbucket.some.corp/vbs/projectr.git (fetch)
team ssh://git@bitbucket.some.corp/vbs/projectr.git (push)
To change to tracking the team instead:
git push --set-upstream team master
You could either delete your current branch and do:
git branch --track local_branch remote_branch
Or change change remote server to the current one in the config
Based on what I understand from the latest git documentation, the synopsis is:
git branch -u upstream-branch local-branch
git branch --set-upstream-to=upstream-branch local-branch
This usage seems to be a bit different than urschrei's answer, as in his the synopsis is:
git branch local-branch -u upstream-branch
git branch local-branch --set-upstream-to=upstream-branch
I'm guessing they changed the documentation again?
In latest git version like 2.7.4,
git checkout branch_name
#branch name which you want to change tracking branch
git branch --set-upstream-to=upstream/tracking_branch_name
#upstream - remote name
I've found @critikaster's post helpful, except that I had to perform these commands with GIT 2.21:
$ git remote set-url origin https://some_url/some_repo
$ git push --set-upstream origin master
참고URL : https://stackoverflow.com/questions/4878249/how-to-change-the-remote-a-branch-is-tracking
'programing tip' 카테고리의 다른 글
MySQL에서 FULL OUTER JOIN을 수행하는 방법은 무엇입니까? (0) | 2020.10.03 |
---|---|
SQL Server에서 char, nchar, varchar 및 nvarchar의 차이점은 무엇입니까? (0) | 2020.10.03 |
Builder Design 패턴과 Factory Design 패턴의 차이점은 무엇입니까? (0) | 2020.10.03 |
git이 자체 서명 된 인증서를 수락하도록하려면 어떻게해야합니까? (0) | 2020.10.03 |
MySQL에서 외래 키 제약 조건을 일시적으로 비활성화하는 방법은 무엇입니까? (0) | 2020.10.03 |