How to update my working Git branch from another branch (develop) ?
I made a new branch for my code like a month ago, I created feature1 branch from develop branch.
⇒ git branch
develop
* feature1
I've been working on feature1 for a month now and a lot of the changes pushed to develop branch, How can I update my current branch feature1 with the latest commits at develop one?
I don't want to checkout master and merge my feature1 branch. Neither I want to use git cherry-pick to manually move commits from develop to feature1.
Any help ?
Solution 1:
You just merge develop to feature1:
git checkout feature1
git merge develop
There is no need to involve another branch such as master.
Solution 2:
First you need to update your develop branch, then checkout your feature and merge/rebase it.
git checkout develop
git pull
git checkout feature/myfeature
Now you can decide between running:
git merge develop
git rebase develop
The difference between merge
and rebase
is that merge
keeps all commits history from your branch, and that is important if your partial commits have a lot of content that can be interesting to keep.
The rebase
option is obligatory in some teams.
When you are ready you can push to your own branch (for example for a pull request)
git push origin feature/myfeature
@timo: Rebase means deleting the commit history from feature and instead have the history from develop