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.
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.
To change which upstream remote is "wired" to your branch, use the git branch
command with the upstream configuration flag.
Ensure the remote exists first:
git remote -vv
Set the preferred remote for the current (checked out) branch:
git branch --set-upstream-to <remote-name>
Validate the branch is setup with the correct upstream remote:
git branch -vv
Working with Git 2.3.2 ...
git branch --set-upstream-to myfork/master
Now status
, push
and pull
are pointed to myfork
remote
上一篇: 获取现有的git分支来跟踪远程分支
下一篇: 改变Git远程'推到'默认值