The second situation where I want to squash some commits:Īnd after that merge request in gitlab and merge in master.I don't merge it in master in feature, because a merge request is created after that for this branch, so this action is doing by another team member as example.Īnd I'm absolutely sure that noone commit in my branch and works with my branch, so as I understand force push is acceptable. git push origin new_feature -f - I'm able to push it only with force because the history is different in current and remote feature branch.if master branch has changes we'll get rebased history of commits in current state.git pull -rebase origin master - because I don't want to have intermediate merge commit When you update your local feature branch using git rebase, you’re rewriting the history.We have master, I need to add some feature, so:.The above example shows how the “feat: Add Pokemon API” commit was pushed to our main branch meaning our feature branch is behind.Is it ok when I do rebase and force push in branch which is used only by me? And will I have a problem after merge this branch in master later? Since it’s not ready we had to use a mock API during the development of the feature.Īt one point our feature branch is going to get behind our main branch: Our crack team of backend developers is working hard on implementing the API. Let’s say we’re working on the Pokemon feature. Using Rebase to Keep Your Branch Up To Date Try to keep things local so you can do whatever you want.Only use rebase if you’re the only person working on a branch (this is why it’s acceptable to force push your changes to a remote branch).Never use rebase on a public branch (you shouldn’t rewrite the history for others and cause problems by force pushing).You can push your branch with git push origin feature/pokemon. Note that if you’re working with a remote branch and want to push changes you have to force push the changes with git push -f ( to your branch only) which is fine if you read the next section. Since rebase changes the project history, once a branch is rebased you may need to force push it to the remote repo. It’s very powerful since it let’s us have a Git History we can reason about. Rebase is one of my favorite Git features.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |