git - 如何在 Intellij 中配置 "update project"以从上游存储库 pull 并推送到分支?

标签 git github intellij-idea git-fork

我正在使用 Intellij 从上游存储库中提取内容,在本地进行更改并推送到我的分支(origin)。我了解如何通过执行获取、正确配置的 pull ,然后正确配置的推送来完成此操作。

我担心的是这里有多个手动步骤。有没有办法将 Intellij 的“更新项目”操作配置为具有不同的默认存​​储库来更新(获取和 pull )并推送到?目前“更新项目”操作仅从当前存储库更新,很容易忘记从上游更新。

最佳答案

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

编号:IDEA-100429是关于考虑 push.default 值,但仍未解决:

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.

IDEA-98693提到 Git Push 对话框不记得远程分支,但是:

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

有关实际示例,请参阅“Pushing into multiple remote repositories simultanously in IntelliJ”。 (它至少适用于推送到不同的远程存储库)

关于git - 如何在 Intellij 中配置 "update project"以从上游存储库 pull 并推送到分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64397948/

相关文章:

git - 将新提交添加到现有 Git 标记

git - 将 Bugzilla 问题迁移到 github 问题跟踪器

git - 无法通过SSH连接到GitHub(但是可以连接到GitLab)

javascript - Intellij 插件 : AirBnB ESLint w/React

php - 如何在本地运行 Laravel git 克隆

git - 使用 GIT 进行源代码控制时,何时应在 TDD 中提交更改?

node.js - Heroku 托管 Microsoft Bot Framework 聊天机器人无法正常工作

linux - 检查从远程分支在本地存储库上创建的 git pull 的历史记录

intellij-idea - IntelliJ 从 Eclipse 飞跃 - 我的面包屑在哪里

android - 将图片目录导入到Android Studio中的drawable资源中