Search code examples
giteclipseegitgit-pullpre-commit

Eclipse Git - Prevent commit before pull


We use Eclipse with Git and we have issues when committing before pulling

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)?

i.e. 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?


Solution

  • 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.

    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.

    I think you need to clarify your issues in your other questions, this is how you will fix your workflow.