Changing the Git remote 'push to' default

后端 未结 11 1923
失恋的感觉
失恋的感觉 2020-12-04 05:35

I want to change the Git default remote branch destination so I could just

git push

Instead of:

git push upstream
         


        
11条回答
  •  时光说笑
    2020-12-04 06:05

    git remote set-url --push origin should work, as you mentioned, but you need to explicitly provide the url instead of an alternative remote name, e.g.

    git remote set-url --push origin git@github.com:contributor/repo.git
    

    You can confirm whether this worked by doing a git remote -v. E.g.

    λ ~/go/src/github.com/stretchr/testify/ master git remote -v
    fork    git@github.com:contributor/testify.git (fetch)
    fork    git@github.com:contributor/testify.git (push)
    origin  git@github.com:stretchr/testify (fetch)
    origin  git@github.com:contributor/testify.git (push)
    

提交回复
热议问题