如何在 Eclipse Neon 中轻松提交 Git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38879650/
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
How to easily Git commit in Eclipse Neon
提问by Garret Wilson
I just upgraded to Eclipse Neon from Mars. Earlier I could just select "Commit" from the "Team" menu, and the dialog would provide checkboxes for the files I wanted to stage. I could easily hit "select all" and all files would be staged. In fact, the files already in the repository would already be checked, if I remember correctly.
我刚刚从火星升级到 Eclipse Neon。早些时候,我可以从“团队”菜单中选择“提交”,对话框将为我想要暂存的文件提供复选框。我可以轻松点击“全选”,所有文件都会被暂存。事实上,如果我没记错的话,已经在存储库中的文件已经被检查过了。
Now Eclipse Neon doesn't pop up a dialog, but shows a "Git Staging" view tab. The modified files are listed as "Unstaged Changes". Yes, I'm familiar with the Git workflow, but this seems a step backwards for the Eclipse UI. How do I "stage" the file? Do I have to select them and drag-and-drop them to "Staged Changes"? Do I have to right click on them and add them to the Index?
现在 Eclipse Neon 不会弹出对话框,而是显示“Git Staging”视图选项卡。修改后的文件列为“Unstaged Changes”。是的,我熟悉 Git 工作流程,但这似乎是 Eclipse UI 的倒退。如何“暂存”文件?我是否必须选择它们并将它们拖放到“分阶段更改”中?我是否必须右键单击它们并将它们添加到索引中?
Whatever happens, it won't let me just hit the "Commit" button---it will complain that there are no unstaged files. Am I missing some way to commit that was as easy as it was in Eclipse Mars, with auto-staging of files or at least a "stage all" button?
不管发生什么,它不会让我只是点击“提交”按钮——它会抱怨没有未暂存的文件。我是否错过了一些像在 Eclipse Mars 中一样简单的提交方式,可以自动暂存文件或至少有一个“暂存”按钮?
回答by Garret Wilson
For the time being I'm disabling the Staging View in Windows > Preferences> Team > Git > Committing, opting to use the old-fashioned Commit Dialog (the one from Eclipse Mars) instead. I don't have time to muck around with extra listbox selections, mouse clicks, and context menu selections just to commit my code.
目前,我正在禁用 Windows > 首选项 > 团队 > Git > 提交中的暂存视图,而是选择使用老式的提交对话框(来自 Eclipse Mars 的对话框)。我没有时间只为了提交我的代码而费心处理额外的列表框选择、鼠标点击和上下文菜单选择。
I hope someone else comes up with a better answer. The Git Staging View was interesting... but not if it slows me down.
我希望其他人提出更好的答案。Git 暂存视图很有趣……但如果它减慢了我的速度就不会了。
回答by ArpitBora
Select YourProject --> Team --> Commit..., A Git Staging console will open.
选择YourProject --> Team --> Commit...,一个 Git Staging 控制台将打开。
Now follow below steps for Commit or Commit and Push changes...
现在按照以下步骤提交或提交并推送更改...
There are two waysto add files in Staged Changes:
- Click "Commit" or "Commit & Push"
回答by pietrodito
There is a default option in Preferences>Git>Commiting : "Automatically stage selected ressources on commit". If this option is checked, all modified files - but with a previous version commited - will be staged automatically as you commit.
Preferences>Git>Commiting 中有一个默认选项:“在提交时自动暂存选定的资源”。如果选中此选项,所有修改过的文件 - 但提交了以前的版本 - 将在您提交时自动暂存。
So this is only when you're adding completely new files to the project that you have to stage them. This is the same with the old dialog where you have to select new files, while the modified files are already selected.
因此,只有当您向项目中添加全新的文件时,您才必须暂存它们。这与旧对话框相同,您必须选择新文件,而已选择修改后的文件。
Another tip to speed up the commit process is that :
另一个加快提交过程的技巧是:
1) The focus is already in the commit message box.
1) 焦点已在提交消息框中。
2) You can hit CTRL+ ENTERto commit when you've finished the message.
2)完成消息后,您可以点击CTRL+ENTER进行提交。
回答by DoesEatOats
I would like to add that creating a local directory on your computer might be a useful idea. Then create a simple text file, put it in that local directory and do a Commit and push to your personal git repo.
我想补充一点,在您的计算机上创建一个本地目录可能是一个有用的想法。然后创建一个简单的文本文件,将其放入该本地目录并执行提交并推送到您的个人 git 存储库。