Should I ask all developers to format the code with the same style?
Yes, that's a good idea.
Projects usually have coding style rules to reduce the likelihood that this is a problem. They can vary from very loose to very strict. Guidelines include but are not limited to layout and formatting.
Most of the developers I worked with are happy to take the style of the project at hand, even if it is not their personal style. This is for the greater good. This facilitates readability and reduces the likelihood that “formatting fixes” will be mixed with real changes. If I edit code that does not have specific style rules, I will try to adhere to the existing style as much as possible.
The worst thing your developers can do is run all the source files using automatic formatting with their own layout rules before committing. This can lead to radical changes in places that were not actually related to the work they performed, and invariably lead to painful merge conflicts when you work across multiple branches.
Can I ask GIT to somehow format the code according to the same style? Can I get automatic code format using BitBucket?
I am going to answer this, disputing why you want to do this. Be careful about locking hooks that automatically format or reject based on the “wrong” style.
This is what code reviews are, and there are always exceptions in the code where a person will do it better (for example, in C ++, clang-format basically does an excellent job, but it sucks up almost everything related to a non-trivial list initializer). Forcing everyone to accept the interpretation of the machine is likely to just get in the way.
paddy source share