简体   繁体   English

如何在Eclipse Neon中轻松实现Git提交

[英]How to easily Git commit in Eclipse Neon

I just upgraded to Eclipse Neon from Mars. 我刚从火星升级到Eclipse Neon。 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. 事实上,如果我没记错的话,已经在存储库中的文件已经被检查过了。

Now Eclipse Neon doesn't pop up a dialog, but shows a "Git Staging" view tab. 现在Eclipse Neon没有弹出对话框,但显示了“Git Staging”视图选项卡。 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. 是的,我熟悉Git工作流程,但这似乎是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? 我是否必须右键单击它们并将它们添加到索引中?

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中一样简单,自动暂存文件或至少是“全部显示”按钮?

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. 目前我正在Windows> Preferences> Team> Git> Committing中禁用Staging View,而是选择使用旧式的Commit Dialog(Eclipse Mars中的一个)。 I don't have time to muck around with extra listbox selections, mouse clicks, and context menu selections just to commit my code. 我没有时间用额外的列表框选择,鼠标点击和上下文菜单选择来提交我的代码。

I hope someone else comes up with a better answer. 我希望别人能得到更好的答案。 The Git Staging View was interesting... but not if it slows me down. Git Staging View很有意思......但如果它减慢了我的速度,那就不行了。

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... 现在按照以下步骤进行提交或提交和推送更改...

  1. There are two ways to add files in Staged Changes: 在分阶段更改中添加文件有两种方法

    • drag and drop the corresponding tree node to the staged changes pane. 相应的树节点拖放到暂存的更改窗格中。 在此输入图像描述
      • click " Add to Git Index " from the context menu. 单击上下文菜单中的“ 添加到Git索引 ”。 在此输入图像描述
  2. Enter the commit message . 输入提交消息 在此输入图像描述

  3. Click " Commit " or " Commit & Push " 点击“ 提交 ”或“ 提交和推送

There is a default option in Preferences>Git>Commiting : "Automatically stage selected ressources on commit". Preferences> Git> Commiting中有一个默认选项:“在提交时自动暂存选定的ressources”。 If this option is checked, all modified files - but with a previous version commited - will be staged automatically as you commit. 如果选中此选项,则所有已修改的文件(但提交的先前版本)将在您提交时自动暂存。

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 + ENTER to commit when you've finished the message. 2)完成消息后,可以按CTRL + ENTER提交。

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仓库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM