How to configure "update project" in Intellij to pull from an upstream repository and push to a fork?

Viewed 992

I'm using Intellij to pull from an upstream repository, make changes locally and push to my fork (origin). I understand how this can be done by doing a fetch, correctly configured pull and then correctly configured push.

My concern is that there are multiple manual steps here. Is there a way to configure Intellij's 'Update Project' operation to have different default repositories to update from (fetch & pull) and push to? Currently 'Update Project' operation just updates from the current repository and it's easy to forget to update from upstream.

1 Answers

Is there a way to configure Intellij's 'Update Project' operation to have different default repositories to update from (fetch & pull) and push to?

No: IDEA-100429 is about considering a push.default value, and is still unresolved:

2020 calling. This remains very annoying for triangular workflow (separate @{push} and @{upstream}) where I can use IntelliJ to multi-branch, multi-commit across projects but need to go into each one and do a "git push" which (with no further config) knows what to do where IntelliJ mistakenly tries to push to @{upstream} instead of honoring the git config.

And IDEA-98693 mentions Git Push dialog does not remember remote branch, but:

Remembering the previous branch you pushed to is bad because among other:

Any branch you push to will be remembered and you accidentally could bush to a wrong branch next time, if e.g. you need to push a branch somewhere only once and then push to the upstream/tracked branch again.

The better approach is to set defaults. It is tracked branch by default, but if it does not work - configure git accordingly.

Remembering branch is useful sometimes, but is not in other cases - there are requests to allow setting default branch to push.

git push behaves differently.

So we reverted the behavior! 2018.1 and further will not remember the last branch but will behave like git push on the commSo and line.
So by default, it will select a branch depending on your git config settings.

So if you want to push to some specific branches (different from default upstream) specify e.g

git config remote.<name>.push refs/heads/LocalBranch:refs/heads/remoteBranch

For a practical example, see "Pushing into multiple remote repositories simultanously in IntelliJ". (it works at least for pushing to a different remote repo)

Related