I usually rebase (git rebase develop
) in this situation, but it depends on whether anyone else has access to your branch? If anyone else has checked out your feature branch, I would not rebase, just do a simple git merge develop
as a rebase will rewrite history and affect other people.
Update my git branch with commits in another branch
-
13-06-2023 - |
Pergunta
My question is probably a simple one, but I am relatively new to using GitHub and wanted to check before I do anything wrong.
Basically, I am working on a feature branch which was cut from the develop branch. I am still working on my feature branch, but another dev has pushed some changes to the develop branch that will affect me.
So, what I want to do is update my branch with all the commits made in the develop branch since I cut my branch from it, but I want both branches to stay separate and my changes to remain in my feature branch (I may have some conflicts to resolve as well)
What is the best thing to do in this situation; rebase?
Solução
Outras dicas
let there be two branches:
- develop
- feature
If you are working in feature and you want changes from develop, follow these steps :
1> Commit all changes in feature branch
git commit -am "message"
2> Checkout to develop branch
git checkout develop
3> Rebase your develop branch
git pull --rebase
4> Checkout to feature branch
git checkout feature
5> Rebase feature against develop
git rebase develop
6> Force push feature branch (!! Be Careful here !!)
git push -f origin feature
Now feature branch has all the changes made in develop as you require.