- 浏览: 2071242 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
http://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-merge-questions
git fetch用来将自己本地的repo 更新到最新的。
但是fetch后,并不会显示到本地。 有两种办法, rebase 和 merge.
if you want masterA => masterB => masterC => yourworkhere => (masterD and E merged) => HEAD then use merge
if you want masterA => B => C => D => E => yourworkhere then use rebase
好了,区别出来了,就是commit的顺序不一样。
一般建议用rebase, 这样可以保持upstream上的顺序。
If you haven’t worked with a version control tool that allows for easy branching, you’re probably wondering what the difference is between rebase and merge and why you’d choose one over the other.
From the standpoint of the end result, a merge and a rebase in Git appear to do the same thing:
A + B + A’ (merge) = A + A’ + B (rebase)
Wouldn’t it be simpler to just choose one operation and stick with it?
The answer of course is no. Otherwise you wouldn’t have the option. (If you feel completely contrary, best of luck. And choose merge.)
It really only becomes apparent once your development effort becomes hierarchical, either in terms of application lifecycle (such as dev, test and release versions) or in a team structure. You’re now dealing with multiple branches, each with non-trivial changes that can and will occur independently.
Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards.
Let’s take a look in more detail at what is actually taking place in each operation for a parent branch A and a child branch B:
Merge
A + B + A’ + dA’B
where A’ are the changes being merged in and dA’B the resolution of merge conflicts from A’ and the set of commits B on the current branch
The changes introduced by A’ and dA’B are grouped together into one merge commit A” = A’ + dA’B that is added on top of the existing set of commits (A + B) and becomes the head of the current branch:
A + B + A”
Rebase
A + A’ + B + dA’B
The rebase resets the starting point the branch and reapplies the set of commits B. Merge conflicts dA’B are combined with these commits so they become grouped together B’ = B + dA’B:
A + A’ + B’
If you stare at it, you’ll realize that the rebase guarantees that the changes being brought it in from the other branch come in exactly as-is: A + A’. Any conflicts are resolved and contained with the associated commits B’ on the current branch.
Using merge to pull in changes from the higher-level branch mixes those changes with the resolved merge conflicts. This means that the current branch won’t necessarily have the same state as the one it was based on (from the hierarchical structure). And since the resolved conflicts are grouped all together in one merge commit, you’ve also made it harder to cleanly cherry-pick individual changes.
Having development lifecycle tracks and each local developer branch start from known consistent states is critical to reducing and resolving code issues. Where a change occurs (or suddenly becomes missing) and who is responsible become easier to determine. By using the rebase to pull in changes, you have that.
When you’re submitting changes back up the chain, you only want to add your changes on top of the existing commits of the higher-level branch. Merge is clearly the operation for that.
Even if you’re a single developer with only a few branches, it’s worth it to get in the habit of using rebase and merge properly. The basic work pattern will look like:
Create new branch B from existing branch A
Add/commit changes on branch B
Rebase updates from branch A
Merge changes from branch B onto branch A
http://gitbook.liuhui998.com/4_2.html
Pro Git中文版:http://progit.org/book/zh/
Git Merge的一个很好的例子讲解:http://blog.microsuncn.com/?p=2000
Git rebase的一个例子讲解:http://blog.microsuncn.com/?p=1989
关于Git rebase和merge的比较的另一个例子:http://gitguru.com/2009/02/03/rebase-v-merge-in-git/
引用
git fetch用来将自己本地的repo 更新到最新的。
但是fetch后,并不会显示到本地。 有两种办法, rebase 和 merge.
if you want masterA => masterB => masterC => yourworkhere => (masterD and E merged) => HEAD then use merge
if you want masterA => B => C => D => E => yourworkhere then use rebase
好了,区别出来了,就是commit的顺序不一样。
一般建议用rebase, 这样可以保持upstream上的顺序。
引用
If you haven’t worked with a version control tool that allows for easy branching, you’re probably wondering what the difference is between rebase and merge and why you’d choose one over the other.
From the standpoint of the end result, a merge and a rebase in Git appear to do the same thing:
A + B + A’ (merge) = A + A’ + B (rebase)
Wouldn’t it be simpler to just choose one operation and stick with it?
The answer of course is no. Otherwise you wouldn’t have the option. (If you feel completely contrary, best of luck. And choose merge.)
It really only becomes apparent once your development effort becomes hierarchical, either in terms of application lifecycle (such as dev, test and release versions) or in a team structure. You’re now dealing with multiple branches, each with non-trivial changes that can and will occur independently.
Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards.
Let’s take a look in more detail at what is actually taking place in each operation for a parent branch A and a child branch B:
Merge
A + B + A’ + dA’B
where A’ are the changes being merged in and dA’B the resolution of merge conflicts from A’ and the set of commits B on the current branch
The changes introduced by A’ and dA’B are grouped together into one merge commit A” = A’ + dA’B that is added on top of the existing set of commits (A + B) and becomes the head of the current branch:
A + B + A”
Rebase
A + A’ + B + dA’B
The rebase resets the starting point the branch and reapplies the set of commits B. Merge conflicts dA’B are combined with these commits so they become grouped together B’ = B + dA’B:
A + A’ + B’
If you stare at it, you’ll realize that the rebase guarantees that the changes being brought it in from the other branch come in exactly as-is: A + A’. Any conflicts are resolved and contained with the associated commits B’ on the current branch.
Using merge to pull in changes from the higher-level branch mixes those changes with the resolved merge conflicts. This means that the current branch won’t necessarily have the same state as the one it was based on (from the hierarchical structure). And since the resolved conflicts are grouped all together in one merge commit, you’ve also made it harder to cleanly cherry-pick individual changes.
Having development lifecycle tracks and each local developer branch start from known consistent states is critical to reducing and resolving code issues. Where a change occurs (or suddenly becomes missing) and who is responsible become easier to determine. By using the rebase to pull in changes, you have that.
When you’re submitting changes back up the chain, you only want to add your changes on top of the existing commits of the higher-level branch. Merge is clearly the operation for that.
Even if you’re a single developer with only a few branches, it’s worth it to get in the habit of using rebase and merge properly. The basic work pattern will look like:
Create new branch B from existing branch A
Add/commit changes on branch B
Rebase updates from branch A
Merge changes from branch B onto branch A
http://gitbook.liuhui998.com/4_2.html
Pro Git中文版:http://progit.org/book/zh/
Git Merge的一个很好的例子讲解:http://blog.microsuncn.com/?p=2000
Git rebase的一个例子讲解:http://blog.microsuncn.com/?p=1989
关于Git rebase和merge的比较的另一个例子:http://gitguru.com/2009/02/03/rebase-v-merge-in-git/
发表评论
-
brew service restart
2013-07-06 22:56 1443brew services restart memcached ... -
git如何合并 多个commit
2013-07-02 20:42 9363需要先搞明白rebase 然后,进这个界面 pick b ... -
rvm create gemset
2013-07-01 09:00 1279rvm ruby-1.9.3-p429 do rvm gems ... -
关于devise结合github通过omniauth登录
2013-06-24 04:47 4152最近写了个github帐户登录Demo: https://gi ... -
cdata 和 xml xmlParseEntityRef: no name 错误
2013-05-04 00:24 4997Problem: An XML parser returns ... -
一目了然 rails html xml encode decode
2013-05-03 23:37 31101.9.2p320 :001 > require ' ... -
使用scope 链接多个where条件
2013-05-02 09:17 2604scope :by_category, (lamb ... -
在rspec里使用 route path
2013-05-01 20:09 1006Rspec.configure do |config| ... -
select_tag default value & options
2013-04-10 21:40 2185#If you are using select_tag ... -
Jquery array remove
2013-04-10 21:38 4531Array.prototype.remove = fu ... -
ruby readline的两种写法
2013-04-09 10:21 897f = File.read('public/file.cs ... -
关于encoding utf-8
2013-04-04 20:55 4081一 gem解决方案 https://github.com/m- ... -
我见过最清楚的解释class_eval 和 instance_eval
2013-04-02 07:06 3322忘了,看一次就能回忆起来 class A # def ... -
multiple provider oauth
2013-04-01 11:13 1293Allowing users to login with mu ... -
oauth github和multiple oauth
2013-04-01 11:08 1542http://railscasts.com/episodes/ ... -
Ruby Jquery 地图,地理信息相关资源
2013-03-22 20:32 932Railscast Geocorder Geocorde ... -
load migrate file and load
2013-03-22 05:52 995Dir[Rails.root.join('db','mig ... -
Brew update problem
2013-03-22 05:48 1339引用 MBA:~ fortin$ brew update er ... -
Jquery sort table number
2013-03-19 01:01 1136So here is what the column is s ... -
update_all
2013-03-13 02:09 1339Article.limit(2).update_all [&q ...
相关推荐
git rebase 和 git merge 的理解与区别 Git 是一个版本控制系统,广泛应用于软件开发过程中。其中,git rebase 和 git merge 是两个常用的命令,都是用于合并分支,但是它们的实现机制和应用场景却有所不同。 git...
Git 是一个分布式版本控制系统,它提供了两种合并分支的策略:`git merge` 和 `git rebase`。两者都是为了整合不同分支的更改,但它们在处理合并的方式上有显著的差异。 ## Git Merge `git merge` 是最常见的合并...
merge主要发生在这样几个地方1 两个人同时开发一个分支,在拉取对方代码的时候2 要将代码合并到master的时候git pull origin master
本文将深入探讨Git的两个关键功能——`merge`和`rebase`,以及它们在日常开发中的应用。 1. **Git的版本控制**:Git的核心功能是版本控制,它能够记录文件的每一次修改,包括修改的内容、作者和时间。这使得开发者...
gti详细的分支操作,在git中,可以使用git merge 和git rebase两个命令来进行分支的合并。 git merge 和git rebase在大体上都差不多,下文主要以git merge来例来讲解分支的合并流程。 如果你想了解分支合并的更多...
`git rebase` 是 Git 中的一个强大功能,主要用于调整提交历史,使其看起来更加线性和简洁。`-i` 参数是 `--interactive` 的简写,意味着用户可以交互式地编辑提交序列。通过这个选项,我们可以选择合并、修改甚至...
3. 合并分支:"VCS" -> "Git" -> "Merge",选择要合并的分支,IDEA会自动解决冲突。 六、解决冲突 1. 当多人修改同一文件时,可能会出现冲突。IDEA会在冲突文件中用特殊标记显示冲突部分。 2. 解决冲突后,需要...
Git 高级使用指南 - merge 和 rebase 的区别 在 Git 中,我们经常会遇到分叉的情况,特别是在多人协作时。当我们执行 `git merge` 命令时,commit 历史就会出现分叉,这种分叉再汇合的结构会让一些人觉得混乱而难以...
文件可能会发生冲突,需要解决一下最后结果* 85ef130 (HEAD -> master) Merge branch 'dev'可以看出,merge 有保留d
在团队协作中,确保每个人都了解如何正确使用 `git merge` 和处理冲突是至关重要的,以防止项目进展受阻。 总之,理解并熟练运用 `git merge` 是 Git 版本控制的关键技能。它不仅涉及到代码的合并,还包括冲突的...
通过这样的练习,你不仅可以熟悉Git的基本操作,还能深入理解Rebase和合并的区别以及它们在实际项目中的适用场景。 记住,掌握Git的这些高级特性对提升团队协作效率和代码管理能力至关重要。不断地实践和探索,你将...
git视频教程.4.6.Git 命令 - git merge、git mergetool.mp4 git视频教程.4.7.Git 命令 - git log、git stash、git tag.mp4 git视频教程.5.1.Git 命令 - git fetch.mp4 git视频教程.5.2.Git 命令 - git pull.mp4 git...
在标签“git”相关的其他知识点中,包括但不限于分支管理(如`git branch`, `git checkout`, `git merge`, `git rebase`)、提交历史查看(`git log`)、回退版本(`git reset`, `git revert`)、标签管理(`git tag...
标题 "test-git-merge-cherry-squash" 暗示了这个压缩包可能包含一个与Git操作相关的示例或教程,特别是关于`git merge`、`git cherry-pick`和`git squash`的实践。Git是分布式版本控制系统,这些命令在版本管理和...
7. **合并策略**:在Git中,`git merge`和`git rebase`是两种常用的合并策略。`git merge`会在历史中创建一个新的merge节点,而`git rebase`则会将你的更改应用到最新的上游分支,保持你的提交历史线性。 - **git ...
高频使用的 Git 命令 Git 作为一个版本控制系统,提供了丰富的命令来帮助开发者管理代码仓库。在日常开发中,我们...但是,在使用 Git 命令时,需要注意一些重要的概念和 beste practice,以避免常见的错误和冲突。
这可以通过`git fetch`、`git rebase`和`git push`来实现。 8. **版本控制** 使用Git flow,你可以更好地管理版本,通过release和hotfix分支确保线上版本的稳定。每次合并到master分支都会创建一个对应的tag,便于...
Git 变更历史可以使用 `git merge` 和 `git rebase` 命令来合并分支。 * `git merge A分支`: 将 A 分支合入到当前分支中且为 merge 创建 commit * `git merge A分支 B分支`: 将 A 分支合入到 B 分支中且为 merge ...