None of the commits in the local repo should have already been pushed to the remote repo. The ideal way of handling this situation is to always rebase only the local repository. Rebasing the remote repository will alter the commit history and will create issues when other developers try to pull the latest code from the remote repository. So Developer 1 will need to take care of a lot of code conflicts ( Even a few redundant code conflicts which were already taken care by developer 2) Now when Developer 1 wants to pull the latest code from remote feature branch, it is a tough job since the commit history has changed.Git won’t allow you since the commit history has changed. Now Developer 2 tries to push the code to the remote feature branch.This is the rebase done from remote to local repo of different branches. So Developer 2 rebases the release branch onto the local feature branch. But Developer 2 also wants to ensure that the latest changes from the release branch is rebased into the feature repository.Developer 2 adds a bunch of commits to the local feature branch.Developer 2 takes the latest changes from the remote feature branch into the local feature branch.Developer 1 has done a bunch of commits and pushed it to remote feature branch.Let’s say 2 developers are working on a feature branch.“green, red, and white high voltage circuit breaker” by Ben Hershey on Unsplash You will have to manually enable it to use it.Īlso if the right git workflows are used, each developer would be having their own feature branches, and such a scenario would not even occur. In fact if you are using a User Interface like source tree, by default force push is disabled. But remember that force push will override the code in the remote repository. Use it only as a last resort if there is no other way to handle a situation. Here we are talking about rebase from remote to local repo in the same branch.Īvoid force push unless absolutely necessary. Once the rebase is done successfully, Developer 2 can push the code into Remote repository. The ideal way of handling the above scenario is Developer 2 needs to pull the latest code changes from the remote repository and rebase the code changes into the local repository. This is because force push overrides the code in the remote repository and hence the existing code in remote repository gets lost. Developer 1 checks the remote repository only to find out the code written by Developer 1 has completely disappeared.Developer 2 does a quick google search and finds out about force push command and uses it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |