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