RStudio git pull button configuration

Is there any way to configure the git pull button so it pulls from an upstream remote, not origin?

The best way is to use Git in the command line. There, you can change the upstream repo for a branch. For example, if you want to switch the upstream repo to be myupstream for the current branch:

git branch --set-upstream-to=myupstream

If you want to change the upstream for all of your branches, you can either change the URL for origin or change the upstream repo for every branch.

Setting the URL for origin:

git remote set-url

Changing the upstream for every branch (I'm sure there's a better way to do this, but it works for me):

for bname in $( git branch --list --format '%(refname:lstrip=2)' ); do
  git fetch myupstream $bname;
  git branch --set-upstream-to=myupstream/$bname $bname;

Thanks. I use the command line to set upstream and then fetch from it following these instructions:

I push branches to origin and then submit a pull request on GitHub -- it sounds like your workflow is more complex. I wasn't aware that there would be a need to set upstream for every branch.

My concern is that it's tempting to click "pull" since that would be the way to sync with origin. It would be helpful if that button could sync with upstream.

I don't think that currently RStudio IDE handles this: You can't choose with remote to use with a branch when pulling with the button.
In fact, the git pull button is synced which whatever remote you git branch is tracking. If you change the remote tracking branch, the effect will change of the pull button with switch. I don't think the is a need to change all branches, for some branches why not.

However, I think you can open a FR on RStudio github repository if not already opened there to share he idea of this improved pull button

For the workflow you describe, do you use usethis :package: ?
There are helpers inside to help with PR and all.

I find them useful and use them myself. Maybe they may help if you don't use them currently.

1 Like

Thanks, thanks for the link and for the FR suggestion.

The back story to this is that I get my students comfortable with a GitHub workflow syncing with their own repos, making extensive use of the push and pull buttons, both with and without branching. Then when we get to forking, cloning and making a contribution to Someone Else's Repo, all of a sudden the pull button is off limits. Maybe that's a good point at which to switch to usethis.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.