Git - Merge

About

Merge is a git merge tool that is designed to integrate changes from one branch into another branch

It joins two or more branch together (ie development histories)

Example

Imagine this commit history (log) with a remote and a local branch where the commit in the remote branch will be integrated into the local branch.

- A - B - C - D - remote HEAD
    \
      E - F - G - local HEAD

After a merge, the commit history (log) will look like:

- A - B - C - D - remote HEAD
    \                         \
      E - F - G - local HEAD - new local HEAD

Management

Merge from master to the feature branch

git checkout feature
git merge master

# or in one liner
git merge master feature

Merge from a fork

See Upstream merge

git-cherry-pick

git-cherry-pick is the low-level merge command.





Discover More
Git - Conflict resolution

In case of conflict during a merge, the working tree files will include a description of the conflict bracketed by the usual conflict markers <<<<<<< and >>>>>>>. For the marker, Git uses the same style...
Git - Fork (Upstream)

A fork is an entire copy of a repository. The original repository of a fork is known as the upstream repository. It has the same concept as a upstream branch. see To sync your local repo with...
Commit History Forked
Git - Forked commit management

This is a page a local fork (ie a local branch). remote fork To incorporate the new commits into your feature branch, you have two options: merging or rebasing. Forked commit history
Git - Pull

git pull incorporates commit (changes) from: a remote repository into the current branch. In its default mode, git pull is a shorthand for: git fetch followed by git merge ie git merge FETCH_HEAD...
Git - Remote branch

A remote branch is a branch in a remote repository. (remote reference). Example: where: and To get the commit from a remote branch, you do a pull (ie a git fetch followed by git...
Git - Stash

git stash stashes the changes in a dirty working directory away before a pull/merge to bring them back later with a local merge. merge (pull do a fetch and merge) git stash pop pops the top stash...
Git - Tracking Branch

Tracking branches are local branches that have set their upstream branch. tracking branchreference The local branches have then a direct relationship with their upstream branch that can be: a remote...
Git - Upstream Branch (Tracking branch)

An upstream is a configuration of a local branch that set the remote branch that it's tracking. cloning @{u} or @{upstream} means the upstream branch of the current branch @{upstream} or @{u}...
Git - rebase

rebase is designed to integrate changes from one branch into another branch. Imagine this commit history (log) with a remote and a local branch where the commit in the remote branch will be integrated...
Merge Mechanism

In Git, the merge mechanisms are: The high level command: git merge and git pull The low-level command: git cherry-pick They allow the backend merge strategies to be chosen (with the -s option)...



Share this page:
Follow us:
Task Runner