kevinlinxp
12/31/2016 - 6:56 AM

Git:merge

Git:merge

## Check conflicts
git checkout <source-branch>
git log HEAD..origin/<dest-branch>

## Fetch and merge 
git fetch origin <dest-branch>
git checkout <source-branch>
git merge FETCH_HEAD
# resolve conflicts if any...
git add -A
git commit
git push
# Merge a source branch into a local dest branch, without checking out the dest branch, when it can be fast-forward
# https://stackoverflow.com/questions/3216360/merge-update-and-pull-git-branches-without-using-checkouts

## Approach 1:
git fetch <remote|.> <source-branch>:<dest-branch>

# Example 1-1:
# Merge local branch foo into local branch master,
# without having to checkout master first.
# Here `.` means to use the local repository as the "remote":
git fetch . foo:master

# Example 1-2:
# Merge remote branch origin/foo into local branch foo,
# without having to checkout foo first:
git fetch origin foo:foo

## Approach 2:
git branch -f <dest-branch> <source-branch>
# This will update branch-dest to point to the head of branch-a.
# The -f option stands for --force, which means you must be careful when using it. Don't use it unless you are sure you the merge will be fast-forward.