2

I committed and pushed changes to the Master branch in GIT today using Eclipse. In our team it is a strict "No".

While I know I have to be careful while pushing any changes to the Master and double check which branch I am working in. I was wondering if there is a way to check the branch and throw a warning if one is working in the master and trying to commit.

Is there a way to set a preference or throw an error message.

Thank you!

Edit:

The question was marked duplicate to a previously asked question: Prevent commits in a local branch

Is there a way to do achieve this pre-commit hook using Eclipse Git-Staging view.

Thanks!

Tuhin Ganguly
  • 31
  • 1
  • 5
  • Yes. If your admin modifies the bitbucket [branch permissions](https://confluence.atlassian.com/bitbucketserver/using-branch-permissions-776639807.html) to "Prevent changes without a pull request" – Elliott Frisch Feb 16 '18 at 03:18
  • Use a pre-commit hook to check commits in your local repo, Use a [pre-receive hook](https://stackoverflow.com/a/35962849/7976758) on a server to prevent pushing to the server. PS. Linked scripts are only examples, not complete solutions. But they are a good start. – phd Feb 16 '18 at 13:22

1 Answers1

0

You can make a admin user who will have write access to master and another user for committing codes who has read only access to master. This would force that the dev creates separate branch from master to commit code. Later merge the branches to master when done.

mans
  • 13
  • 4