Reputation: 10405
I've joined a project in recent days. The owner of the project asked his previous developer a feature and since he was not happy he asked me to do the same thing.
The project is maintained on GitLab and the previous developer pushed his new changes to master branch before me and now when I'm going to push my changes, it is rejected by remote server (GITLAB servers).
According to gitlab documentation, there is no push force
option on git lab repositories for any of roles on protected branches specifically on master (which can be turned off).
I want to know if I have no other options to turn off protection on master branch and then force push my changes or there are some better options?
I ask this since me and other developer worked on the same feature and probable merging of our changes may lead to unpredictable results (I'm not sure).
Upvotes: 2
Views: 732
Reputation: 311808
An alternative approach would be to revert the other developer's changes, and then apply your changes on top of that revert.
Start from the master branch and create the new branch:
$ git checkout -b branch_to_push
Then, from that branch, revert the "wrong" implementation of the feature. If it's a single commit:
$ git revert <commit-hash>
If it's comprised of multiple commits:
$ git revert '<commit-hash-earliest>^1..<commit-hash-latest>'
Cherry-pick your implementation from your branch:
$ git cherry-pick feature_branch
And then just push this branch to review in GitLab:
$ git push origin branch_to_push
Upvotes: 2