Intellij IDEA 如何使用 git 插件将项目上传到远程分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14051525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Intellij IDEA how to upload project to remote branch with git plugin?
提问by Dmytro Danylyk
I have Intellij IDEA 12.0.1 I am using build-in Git plugin. I am able to create local repository. Now I want to upload my source code to remote repository. Can I do this with Intellij IDEA plugin?
我有 Intellij IDEA 12.0.1 我正在使用内置 Git 插件。我能够创建本地存储库。现在我想将我的源代码上传到远程存储库。我可以用 Intellij IDEA 插件做到这一点吗?
Thank you.
谢谢你。
回答by Dmytro Danylyk
You can't upload your local Git repository to remote using IntelliJ IDEA plugin. For this you need to use Git Bashor Git client, for example Source Tree.
您无法使用 IntelliJ IDEA 插件将本地 Git 存储库上传到远程。为此,您需要使用Git Bash或 Git 客户端,例如Source Tree。
To create local Git repository with IntelliJ IDEA plugin
使用 IntelliJ IDEA 插件创建本地 Git 存储库
- In IntelliJ IDEA menu
VCS -> Import into Version Control -> Create Git Repository
- In pop up window select your project and click ok.
- Commit all necessary files to you local branch
master
- 在 IntelliJ IDEA 菜单中
VCS -> Import into Version Control -> Create Git Repository
- 在弹出窗口中选择您的项目并单击确定。
- 将所有必要的文件提交到您的本地分支
master
To upload local repository to remote using Git Bash
使用 Git Bash 将本地存储库上传到远程
- Open Git Bashand navigate to your project folder e.g cd
'D:\projects\TestProject'
- In Git Bash
git remote add origin http//IP/path/to/repository
- In Git Bash
git push origin master
- In IntelliJ IDEAright-click on project select
Synchronize 'TestProject'
- In IntelliJ IDEAright-click on project select
Git -> Repository -> Branches -> origin/master -> Checkout as new local branch
- 打开Git Bash并导航到您的项目文件夹,例如 cd
'D:\projects\TestProject'
- 在Git Bash 中
git remote add origin http//IP/path/to/repository
- 在Git Bash 中
git push origin master
- 在IntelliJ IDEA 中右键单击项目选择
Synchronize 'TestProject'
- 在IntelliJ IDEA 中右键单击项目选择
Git -> Repository -> Branches -> origin/master -> Checkout as new local branch
To upload local repository to remote using Source Tree
使用 Source Tree 将本地存储库上传到远程
- In Source Tree
File -> Open
and navigate to your project folder e.g cd'D:\projects\TestProject'
- In Source Tree
Repository -> Add Remote
, you should see Repository Settingswindow - Click Addbutton, and fill Remote details
- Finally click Okbutton Now you should be able to do pull/push using IntelliJ IDEA plugin.
- In IntelliJ IDEAright-click on project select
Synchronize 'TestProject'
- In IntelliJ IDEAright-click on project select
Git -> Repository -> Branches -> origin/master -> Checkout as new local branch
- 在源树中
File -> Open
并导航到您的项目文件夹,例如 cd'D:\projects\TestProject'
- 在Source Tree 中
Repository -> Add Remote
,您应该看到Repository Settings窗口 - 单击添加按钮,并填写远程详细信息
- 最后单击Ok按钮现在您应该可以使用 IntelliJ IDEA 插件进行拉/推。
- 在IntelliJ IDEA 中右键单击项目选择
Synchronize 'TestProject'
- 在IntelliJ IDEA 中右键单击项目选择
Git -> Repository -> Branches -> origin/master -> Checkout as new local branch
Now you should be able to do pull/pushusing IntelliJ IDEAplugin.
现在您应该能够使用IntelliJ IDEA插件进行拉/推。
回答by taher
It is possible in Intellij IDEA.
You should add a remote repository for your local repository in git bash by below command.
这在 Intellij IDEA 中是可能的。
您应该通过以下命令在 git bash 中为本地存储库添加远程存储库。
git remote add origin YOUR_REMOTE_REPOSITORY_ADDRESS.
for example
git remote add origin https://gitlab.com/my_account/my_repository.git
In Intellij IDEA when you want to commit any change to repository use ctrl + k
and it will show you a window like below image. In this window you can choose commit and push
so it will commits and push change to local and remote repository.Also if you want to only push to remote repository use
ctrl + shift + k
to pushing changes.
I hope this answer helps you.
在 Intellij IDEA 中,当您想要提交对存储库使用的任何更改时ctrl + k
,它会显示一个如下图所示的窗口。在此窗口中,您可以选择commit and push
将更改提交并推送到本地和远程存储库。此外,如果您只想推送到远程存储库,请使用
ctrl + shift + k
推送更改。
我希望这个答案对你有帮助。
回答by Karthic Raghupathi
I had the same problem and I believe this is still the case with IDEA 12 unless I'm mistaken:
我遇到了同样的问题,我相信 IDEA 12 仍然如此,除非我弄错了:
An alternative to using the command line would be SourceTree (available for Mac & Win) to manage remotes or manage Git/Hg repositories completely. It is a free GUI client from Atlassian (no affiliation disclosure).
使用命令行的替代方法是 SourceTree(适用于 Mac 和 Win)来管理远程或完全管理 Git/Hg 存储库。它是来自 Atlassian 的免费 GUI 客户端(无从属关系披露)。
You can download it here.
你可以在这里下载。