I will use these two branches in this example:
dev
- the main branchfeature
- the newly created branch
Always rebase before a merge
# checkout new branch
> git checkout -b feature
# make commits
> ...
# make a pull with rebase before merge (if long branch, do occasional rebases)
> git checkout dev
> git pull --rebase
> git checkout feature
> git rebase dev
# merge when done
> git checkout dev
> git merge feature
# delete branch
> git branch -d feature