diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index 74a88ff983..295f5902fe 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -20,8 +20,18 @@ export const PushPull = () => { useEffect(() => { setRemoteBranch(context.currentBranch.name) setLocalBranch(context.currentBranch.name) - if ((!context.upstream) && context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.name) { - actions.setUpstreamRemote(context.currentBranch.remote) + + let currentUpstreamIsInRemotes = context.upstream && context.remotes.find(r => r.name === context.upstream.name) + if (!context.upstream || !currentUpstreamIsInRemotes) { + if (context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.name) { + actions.setUpstreamRemote(context.currentBranch.remote) + } else { + if (context.remotes && context.remotes.length > 0) { + actions.setUpstreamRemote(context.remotes[0]) + } else{ + actions.setUpstreamRemote(null) + } + } } }, [context.currentBranch, context.remotes, context.branches]) @@ -115,7 +125,7 @@ export const PushPull = () => { .map(repo => { return { value: repo.name, label: repo.name } }) - + console.log('options', options) setLocalRemotesOptions(options) }, [context.remotes])