简体   繁体   English

Eclipse Git - 在拉取前防止提交

[英]Eclipse Git - Prevent commit before pull

We use Eclipse with Git and we have issues when committing before pulling我们将 Eclipse 与 Git 一起使用,并且在拉取之前提交时遇到问题

Currently we don't use pull request, but direct pushes to the main/master branch.目前我们不使用拉取请求,而是直接推送到主/主分支。 and failing to (commit and) push because of old commits not pull causes difficulty to merge commits later.并且由于旧的提交而未能(提交和)推送导致以后难以合并提交。

Can we ensure/prevent commit(/push) before pulling latest commit(s)?我们可以在拉最新提交之前确保/防止提交(/推送)吗?

ie can we execute in atomic operation pull and commit (and maybe push) instead of just commit?即我们可以在原子操作中执行拉取和提交(也可能是推送)而不是仅仅提交吗?

Or alternatively can we do a automatic rebase before push?或者我们可以在推送之前进行自动变基吗?

You can't really prevent someone to commit before pulling, and given git distributed nature, it doesn't make much sense : even when you pull, you have no way to know if the remote has been updated by someone else in the next second.你不能真正阻止某人在 pull 之前提交,并且鉴于git分布式的性质,这没有多大意义:即使你 pull,你也无法知道遥控器是否在下一秒被其他人更新.

Any git workflow has a part that says : if my local changes are not up to date with the remote changes, I have to decide what to do with the remote changes (integrate them ? squash them ?) before pushing.任何 git 工作流程都有一部分说明:如果我的本地更改与远程更改不同步,我必须在推送之前决定如何处理远程更改(整合它们?压缩它们?)。

I think you need to clarify your issues in your other questions, this is how you will fix your workflow.我认为您需要在其他问题中澄清您的问题,这就是您修复工作流程的方式。

Here's what I would like: a checkbox in Eclipse preferences so that when I try to do a local commit there will be a check if my local repo is up to date.这是我想要的:Eclipse 首选项中的一个复选框,这样当我尝试进行本地提交时,将检查我的本地存储库是否是最新的。

So... I make some changes and try to do a local commit.所以...我进行了一些更改并尝试进行本地提交。 Eclipse does a fetch and since there has been a change I get a warning that reads "Project not up to date with origin. Continue commit or cancel?" Eclipse 执行提取,并且由于发生了更改,我收到一条警告,内容为“项目与原点不同步。继续提交还是取消?”

Most likely I cancel, pull in the changes, and then try my commit again.很可能我取消,拉入更改,然后再次尝试提交。

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

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