'Normal' Merge

In case of a normal merge, a merge commit with at least two parent commits (i.e., the last from the current branch and the last from the merged branch) is created. See the following figure, where > indicates where the HEAD is pointing to:

                            o [> master]
                            |\
o [> master]                o \
|                  ==>      |  |
|  o [a-branch]             |  o [a-branch]
.  .                        .  .

Fast-forward Merge

If the current branch is completely included in the branch to be merged with (i.e. the latter is simply a couple of commits ahead), then no extra merge commits is created. Instead, the branch pointer of the current branch is moved forward to match the branch pointer of the other branch, as shown below:

o [origin/master]             o [> master][origin/master]
|                     ==>     |
o [> master]                  o
.                             .

In SmartGit, there are several places from which you can initiate a merge:

  • Menu and toolbar On the main window, select Branch|Merge to open the Merge dialog, where you can select the branch to be merged into the current branch. Depending on your toolbar settings, you can also open this dialog via the Merge button on the toolbar.
  • Branches view In the Branches view (available both on the main window and the Log window), you can right-click on a branch and select Merge to merge the selected branch into the current branch.
  • Log Graph On the Log graph of the Log window, you can perform a merge by right-clicking on the head commit of the branch to be merged with and selecting Merge from the context-menu.

Regardless of where you invoked the Merge command, you will be given the choice between Create Merge-Commit and Merge to Working Tree, and optionally also Fast-Forward if a fast-forward merge is possible.

If you choose Create Merge-Commit, SmartGit will perform the merge and create a merge commit, assuming there are no merge conflicts. If there are merge conflicts, or if you choose Merge to Working Tree, SmartGit will perform the merge, but leave the working tree in a merging state, so that you can manually resolve merge conflicts and review the changes to be made. See Resolving Conflicts for further information on how to deal with merge conflicts.

Squash Merge

The squash merge works like a normal merge, except that it discards the information about where the changes came from. Hence it only allows you to create normal commits. The squash merge is useful for merging changes from local (feature) branches where you don't want all of your feature branch commits to be pushed into the remote repository.

    o [> master] (changes from a-branch)
    |
o [> master]                o
|                  ==>      |
|  o [a-branch]             |  o [a-branch]
.  .                        .  .

On the Commit dialog, you can choose between a normal merge (merge commit) and a squash merge (simple commit). Thus, to perform a squash merge you have to choose Merge to Working Tree when initiating the merge, since otherwise you won't see the Commit dialog.

Merge versus Rebase

A Git-specific alternative to merging is rebasing (see Rebase), which can be used to keep the history linear. For example, if a user has made local commits and performs a pull with merge, a merge commit with two parent commits - the user's last commit and the last commit from the tracked branch - is created. When using rebase instead of merge, Git applies the local commits on top of the commits from the tracked branch, thus avoiding a merge commit.

Resolving Conflicts

When a merge, a cherry-pick or a rebase fails due to conflicting changes, SmartGit stops the operation and leaves the working tree in a conflicted state, so that you can either abort the operation, or resolve the conflicts and continue with the operation. This section explains how you can do that with SmartGit. Generally, the following options are available:

  • Resolve dialog If you select a file containing conflicts and then invoke Local|Resolve in the menu of SmartGit's main window, the Resolve dialog will come up, where you can set the file's contents to either of the two conflicting versions, i.e. `Ours' or `Theirs'. Optionally, you may also choose not to stage the resetting of the file contents, meaning that the conflict marker on that file won't be removed.
  • Conflict Solver Selecting a file containing conflicts and invoking Query|Conflict Solver will open the Conflict Solver, a three-way diff between the two conflicting versions (left and right editor) and a third version (center editor) that contains the conflicting hunks from both sides, along with conflict markers. You can directly edit the text in the center editor, and you can move changes from the left and right side into the center by clicking on the arrow and `x' buttons between the editors.
  • Discard command To abort the merge, cherry-pick or rebase, select the repository in the Repositories view and invoke Local|Discard.

Lastly, if all conflicts have been resolved, you can continue with the merge, cherry-pick or rebase by selecting the repository in the Repositories view and invoking Local|Commit.

Cherry-Pick

The Cherry-Pick command allows you to 'apply' certain commits from another branch to the current branch.

o                        o  C' [> master]
|                        |
o  [> master] A          o  A
|                        |
|   o  [a-branch]        |   o  [a-branch]
|   |                    |   |
o   |  B                 o   |  B
|   |                    |   |
|   o  C (selected)      |   o  C
|   |                    |   |
o   |  D       ===>      o   |  D
|  /        cherry-pick  |  /
| /                      | /
o                        o

In SmartGit, there are several places from which you can initiate a cherry-pick:

  • Menu and toolbar On the main window, select Branch|Cherry-Pick to open the Cherry-Pick dialog, where you can select one or more commits to cherry-pick. Depending on your toolbar settings, you can also open this dialog via the Cherry-Pick button on the toolbar.
  • Log Graph On the Log graph of the Log window, you can perform a cherry-pick by right-clicking on one or more commits and selecting Cherry-Pick from the context-menu.

Revert

The Revert command allows you to 'undo' certain commits (from whatever branch) in the current branch.

o                        o  reversed-C  [> master]
|                        |
o  [> master] A          o  A
|                        |
|   o  [a-branch]        |   o  [a-branch]
|   |                    |   |
o   |  B                 o   |  B
|   |                    |   |
|   o  C (selected)      |   o  C
|   |                    |   |
o   |  D         ===>    o   |  D
|  /            revert   |  /
| /                      | /
o                        o

In SmartGit, there are several places from which you can initiate a Revert:

  • Menu and toolbar On the main window, select Branch|Revert to open the Revert dialog, where you can select one or more commits to revert. Depending on your toolbar settings, you can also open this dialog via the Revert button on the toolbar.
  • Log Graph On the Log graph of the Log window, you can perform a revert by right-clicking on one or more commits and selecting Revert from the context-menu.

smartgit document merge的更多相关文章

  1. smartgit document Rebase

    The Rebase command allows you to apply commits from one branch to another. Rebase can be viewed as m ...

  2. ElasticSearch 2 (5) - Document APIs

    ElasticSearch 2.1.1 (5) - Document APIs This section describes the following CRUD APIs: Single docu ...

  3. multiple merge document

    http://www.aspose.com/docs/display/wordsnet/How+to++produce+multiple+documents+during+mail+merge

  4. SmartGit STUDY 2

    The Index The Index is an intermediate cache for preparing a commit. With SmartGit, you can make hea ...

  5. jQuery静态方法inArray,grep,merge,makeArray方法使用和源码分析

    inArray方法 确定第一个参数在数组中的位置,从0开始计数(如果没有找到则返回 -1 ). 示例: var arr = [ 4, "Pete", 8, "John&q ...

  6. jquery工具方法makeArray/merge

    makeArray : 类数组转真数组 merge : 合并数组或转特殊json 使用例子(外部使用): var aDiv = document.getElementsByTagName('div') ...

  7. SmartGit as SVN Bridge

    This page provides an introduction to SmartGit from an SVN users perspective and shows how the SVN w ...

  8. SmartGit STUDY

    Git Concepts This section helps you to get started with Git and gives you an understanding of the fu ...

  9. [RxJS] Handling Multiple Streams with Merge

    You often need to handle multiple user interactions set to different streams. This lesson shows hows ...

随机推荐

  1. HDU 1312 Red and Black --- 入门搜索 DFS解法

    HDU 1312 题目大意: 一个地图里面有三种元素,分别为"@",".","#",其中@为人的起始位置,"#"可以想象 ...

  2. HMTL—表单

    <body> <form> 账号:<input type="text" value="123" /> <br /> ...

  3. Python如何规定对方输入的数字必须是整数?

    可以使用字符串str的isdigit方法判断字符串是否是一个仅有数字组成,也就是整数.如果是整数退出while循环,否则继续请求输入. 1 2 3 4 5 6 while True:     x =  ...

  4. JAVA 新闻

    Oracle已对Java失去兴趣?Java社区能否扭转乾坤? http://news.cnblogs.com/n/549566/ http://mp.weixin.qq.com/s?__biz=MjM ...

  5. Firefox-常用扩展

    抓包: HttpFox,相比 Firebug 在页面跳转或刷新时依旧保持原有数据 常用User-Agent模拟: User Agent Switcher 更改请求头: ModifyHeaders 更改 ...

  6. sql 2000 NOLOCK 和 ROWLOCK 和 UPDLOCK

    关系型数据库,如SQL Server,使用锁来避免多用户修改数据时的并发冲突.当一组数据被某个用户锁定时,除非第一个用户结束修改并释放锁,否则其他用户就无法修改该组数据. 有些数据库,包括SQL Se ...

  7. 【转】Javascript+css 实现网页换肤功能

    来源:http://www.php100.com/html/webkaifa/DIV_CSS/2008/1014/2326.html Html代码部分: 1.要有一个带id的样式表链接,我们要通过操作 ...

  8. 递归函数练习:输出菲波拉契(Fibonacci)数列的前N项数据

    /*====================================================================== 著名的菲波拉契(Fibonacci)数列,其第一项为0 ...

  9. LINUX系统下PHP显示空白页

    因为手工转移,文件所属用户及用户组是root,所以需要把网站程序及数据库都改成对应用户组:如www和mysql. 更改目录所属用户执行命令: chown -R 用户.用户组 目录名, 如:chown ...

  10. html之hr,form标签

    <hr>标签:在html页面中创建一条水平线,可在视觉上将文档分隔成多个部分 <form>:块级标签,前后会产生折行 标签用于为用户输入创建html表单,将数据提交给服务器.表 ...