Version Control System, IntelliJ IDEA, Create a Git Repository for a Project and push to multiple remotes
A Usage Sample and Notes
Let's focus on how would you switch Git remote repository? or adding multiple remote repository to sync with local branch,
Use cases: if you want to switch GitHub to GitLab or from GitLab to GitHub services.
if you want to add both GitHub and GitLab to sync with your local projects.
We can follow bellow steps in IntelliJ IDEA:
- Menu VCS > Enable Version Control Integration
- This will create/add git system to local driver/disk
- After Commit to local branches
- Usually we allready have lots of files, and historical commits...
- Menu VCS > Git > Remotes
- add renew remote, so new remote repository is connected.
- named initial: origin, Now we could adding multiple remote origin, I.e. origin_gitlab...
- Please Note: we can add multiple remotes as desired.
- Menu VCS > Git > Fetch
- got sync from remote repositroy, but not yet merge with your local branches.
- Now local and remote repository and commit is all in local driver, under git control, ready for next action.
- Note: if we have multiple Remotes, the tool will try to fetch remote branches and commits one by one, and ignore anyone if it failed to fetch(Let's say one of the Account is closed)
- Menu VCS > Git > Branches > New Branch
- Now depends on which local branch we currently working on, we can merge or push local commits to remote branches; in my example, I will create a new Local Branch(I.e. SynctoGitLab) from master, and push it to gitlab remote repository.
- New Branch, will create a local new branch and contains all of the files and commits of 'master'(usually)
- Menu VCS Git > Push
- NOW we can control how and where to push to, means to control push local new branch to which remote repository.
- [Push commits to ***] In the left hand of the window, selected the local new created branch means which local branch to sync from. "SynctoGitLab -> origin : SynctoGitLab" new
- Click on origin to chose the desired remote(git repository), i.e. new added remote: origin_gitlab.
- so Now it becomes: "SynctoGitLab -> origin_gitlab : SynctoGitLab" new
- that means it will sync/push local branch "SynctoGitLab" to remote "origin_gitlab" new branch "SynctoGitLab", yes, it will create a new branch and sync with the local branch; now everything got in sync.
- We can operat Push again and push it to another remote(and so another same naming branch)
Share learning informations:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话