Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

Changing the Git remote 'push to' default

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

git push

Instead of:

git push upstream

Currently this is set to the origin remote and I want to set it to a different remote.

I tried to remove the original (cloned from) remote

git remote rm origin

Which did remove the original remote. But doesn't solve the git push problem. I still get:

fatal: No configured push destination. Either specify the URL from the
command-line or configure a remote repository using...

I also tried to play with:

git remote set-url --push myfork origin

and other options but none seem to work (maybe because I deleted the origin remote too soon?)

Following the answer here I tried to change:

git config push.default upstream (or matching)

but neither worked.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

You can use git push -u <remote_name> <local_branch_name> to set the default upstream. See the documentation for git push for more details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...