之前记录了:
[记录]Xcode中git merge branch到master上
也折腾过多次的rebase,但是好像都是快把过程搞晕了。
这次,好好去整理对应的过程:
1.xcode中,提交当前branch(message_layout)的内容到远端到服务器了
忘了截图。。
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch message_layout
Your branch is up-to-date with ‘origin/message_layout’.
nothing to commit, working directory clean
后来另外一次,截了图:
2.git checkout master
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout master
Switched to branch ‘master’
Your branch is up-to-date with ‘origin/master’.
3.git pull
==git pull origin master
licrifandeMacBook-Pro:iOS-Client crifan$ git pull
remote: Counting objects: 55, done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 55 (delta 20), reused 0 (delta 0)
Unpacking objects: 100% (55/55), done.
From https://git.oschina.net/windoze/iOS-Client
f0d7f09..d5bb621 master -> origin/master
Updating f0d7f09..d5bb621
Fast-forward
JianDao/FileDownloadViewController.swift | 57 ++–
JianDao/FileManageViewController.swift | 673 +++++++++++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<———
JianDao/FileTableViewCell.swift | 277 +++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<–
JianDao/FileViewController.swift | 294 ++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<
JianDao/GlobalFunctions.swift | 6 +–
JianDao/ImageViewController.swift | 13 +–
…/File/icon_large/file_icon_large_audio.imageset/file_icon_large_audio.png | Bin 1489 -> 1835 bytes
……
JianDao/JianDao/Constants.swift | 8 +–
JianDao/LoginViewController.swift | 2 +–
JianDao/MainViewController.swift | 2 +–
JianDao/MessageTableViewController.swift | 4 +–
JianDao/ResourceUtility.swift | 19 +
39 files changed, 1012 insertions(+), 345 deletions(-)
4.git checkout message_layout
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout message_layout
Switched to branch ‘message_layout’
Your branch is up-to-date with ‘origin/message_layout’.
5.git rebase master
此处由于改动太大,导致冲突很多:
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
First, rewinding head to replay your work on top of it…
Applying: 1. optimize message table view cell layout -> added text/file/image view and unify all layout
Using index info to reconstruct a base tree…
M JianDao/FileDownloadViewController.swift
M JianDao/FileViewController.swift
M JianDao/GlobalFunctions.swift
M JianDao/ImageViewController.swift
M JianDao/JianDao/Constants.swift
M JianDao/LoginViewController.swift
M JianDao/MainViewController.swift
M JianDao/MessageTableViewController.swift
M JianDao/ResourceUtility.swift
.git/rebase-apply/patch:112: trailing whitespace.
.git/rebase-apply/patch:144: trailing whitespace.
.git/rebase-apply/patch:147: trailing whitespace.
.git/rebase-apply/patch:169: trailing whitespace.
.git/rebase-apply/patch:197: trailing whitespace.
warning: squelched 258 whitespace errors
warning: 263 lines add whitespace errors.
Falling back to patching base and 3-way merge…
Auto-merging JianDao/ResourceUtility.swift
Auto-merging JianDao/MessageTableViewController.swift
CONFLICT (content): Merge conflict in JianDao/MessageTableViewController.swift
Removing JianDao/MessageBubbleView.swift
Removing JianDao/MessageBubbleFactory.swift
Auto-merging JianDao/MainViewController.swift
Auto-merging JianDao/LoginViewController.swift
Auto-merging JianDao/JianDao/Constants.swift
CONFLICT (content): Merge conflict in JianDao/JianDao/Constants.swift
Auto-merging JianDao/ImageViewController.swift
CONFLICT (content): Merge conflict in JianDao/ImageViewController.swift
Removing JianDao/ImageBubbleView.swift
Auto-merging JianDao/GlobalFunctions.swift
Auto-merging JianDao/FileViewController.swift
CONFLICT (content): Merge conflict in JianDao/FileViewController.swift
Auto-merging JianDao/FileMessageView.swift
Auto-merging JianDao/FileDownloadViewController.swift
error: Failed to merge in the changes.
Patch failed at 0001 1. optimize message table view cell layout -> added text/file/image view and unify all layout
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase –continue".
If you prefer to skip this patch, run "git rebase –skip" instead.
To check out the original branch and stop rebasing, run "git rebase –abort".
然后先去修复CONFLICT
解决了上述几个文件的冲突后,Xcode中,再去标记冲突已解决
然后回来,继续git rebase –continue:
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
JianDao/FileManageViewController.swift: needs update
JianDao/FileTableViewCell.swift: needs update
You must edit all merge conflicts and then
mark them as resolved using git add
然后添加上文件:
licrifandeMacBook-Pro:iOS-Client crifan$ git add JianDao/FileManageViewController.swift
licrifandeMacBook-Pro:iOS-Client crifan$ git add JianDao/FileTableViewCell.swift
就可以继续了
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
Applying: 1. optimize message table view cell layout -> added text/file/image view and unify all layout
和:
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch message_layout
Your branch and ‘origin/message_layout’ have diverged,
and have 2 and 1 different commit each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch message_layout is up to date.
再切换到master:
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout master
Switched to branch ‘master’
Your branch is up-to-date with ‘origin/master’.
在将branch中的内容,合并到master中:
git merge message_layout
licrifandeMacBook-Pro:iOS-Client crifan$ git merge message_layout
Updating d5bb621..55597d8
Fast-forward
JianDao/Conversation.swift | 17 +–
JianDao/ConversationUtility.swift | 10 +–
JianDao/ConversationViewController.swift | 323 +++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—————-
JianDao/FileDownloadViewController.swift | 2 +–
JianDao/FileManageViewController.swift | 4 +–
JianDao/{FileBubbleView.swift => FileMessageView.swift} | 84 ++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—-
JianDao/FileTableViewCell.swift | 10 +–
JianDao/FileViewController.swift | 254 ++++++++++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<–
JianDao/GlobalFunctions.swift | 31 +<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<-
JianDao/GlobalValues.swift | 7 +–
JianDao/ImageBubbleView.swift | 172 <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—————–
JianDao/ImageMessageView.swift | 266 +++++++++++++++++++++++++++++
JianDao/ImageViewController.swift | 22 +<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<
JianDao/JianDao.xcodeproj/project.pbxproj | 28 ++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<
JianDao/JianDao/Constants.swift | 44 ++++–
JianDao/LoginViewController.swift | 94 ++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—
JianDao/MainViewController.swift | 75 ++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<-
JianDao/Message.swift | 17 +–
JianDao/MessageBubbleFactory.swift | 46 <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—
JianDao/MessageBubbleView.swift | 171 <span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—————–
JianDao/MessageManager.swift | 379 +++++++++++++++++++++++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<–
JianDao/MessageTableViewCell.swift | 522 +++++++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<———————————-
JianDao/MessageTableViewController.swift | 378 +++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<———————-
JianDao/MessageUtility.swift | 77 +++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<–
JianDao/RegisterPhoneViewController.swift | 1 +
JianDao/ResourceUtility.swift | 102 +++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—-
JianDao/TeamTableViewData.swift | 42 ++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<-
JianDao/TextMessageView.swift | 127 ++++++++++++++
28 files changed, 1805 insertions(+), 1500 deletions(-)
rename JianDao/{FileBubbleView.swift => FileMessageView.swift} (55%)
delete mode 100644 JianDao/ImageBubbleView.swift
create mode 100644 JianDao/ImageMessageView.swift
delete mode 100644 JianDao/MessageBubbleFactory.swift
delete mode 100644 JianDao/MessageBubbleView.swift
create mode 100644 JianDao/TextMessageView.swift
再把本地的更新后的master,上传到远端服务器:
git push
licrifandeMacBook-Pro:iOS-Client crifan$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the traditional behavior, use:
git config –global push.default matching
To squelch this message and adopt the new behavior now, use:
git config –global push.default simple
When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.
See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)
Counting objects: 41, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (41/41), done.
Writing objects: 100% (41/41), 84.87 KiB | 0 bytes/s, done.
Total 41 (delta 24), reused 0 (delta 0)
To https://git.oschina.net/windoze/iOS-Client.git
d5bb621..55597d8 master -> master
再去贴上一个例子,是master中没有更新的内容的,所以比较简单:
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch contact_store
Your branch is up-to-date with ‘origin/contact_store’.
nothing to commit, working directory clean
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout master
Switched to branch ‘master’
Your branch is up-to-date with ‘origin/master’.
licrifandeMacBook-Pro:iOS-Client crifan$ git pull
Already up-to-date.
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout contact_store
Switched to branch ‘contact_store’
Your branch is up-to-date with ‘origin/contact_store’.
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch contact_store is up to date.
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout master
Switched to branch ‘master’
Your branch is up-to-date with ‘origin/master’.
licrifandeMacBook-Pro:iOS-Client crifan$ git merge contact_store
Updating b92479f..8ab757e
Fast-forward
JianDao/ContactUtility.swift | 27 +++++++++++++++
JianDao/ContactViewController.swift | 19 +++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<——
JianDao/Conversation.swift | 31 +++++++++++++++++
JianDao/ConversationViewController.swift | 26 ++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<—
JianDao/FileMessageView.swift | 4 +<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<
JianDao/GroupTopicTableViewController.swift | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="font-family: Monaco; font-size: 12px; color: rgb(51, 51, 51);"–<———————-
JianDao/LoginViewController.swift | 7 +++–
7 files changed, 228 insertions(+), 68 deletions(-)
licrifandeMacBook-Pro:iOS-Client crifan$ git push
Total 0 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/windoze/iOS-Client.git
b92479f..8ab757e master -> master
licrifandeMacBook-Pro:iOS-Client crifan$
[总结]
背景:
基于之前某个时间节点时最新的master版本
去新建了个branch,
然后在branch中做了多次更新
现在想要执行rebase,合并branch的更新到主分支master中
具体过程是:
1.把branch中的更新,上传到服务器中
-》可以通过Xcode中的Commit
-》也可以通过git命令行
2.git checkout master
3.git pull
-》切换到主分支中,去更新最新的服务器的改动
4.git checkout branch_name
5.git rebase master
->正常的话,没有冲突,则会自动合并,则rebase完成,否则:
-》如果有冲突,则根据提示去解决冲突,并且标记文件为已解决冲突
-》在Xcode中mark has resolved
-》回来还要去命令行中用git去add进来对应的文件
-》然后用git rebase –continue继续rebase:
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
JianDao/FileManageViewController.swift: needs update
JianDao/FileTableViewCell.swift: needs update
You must edit all merge conflicts and then
mark them as resolved using git add
licrifandeMacBook-Pro:iOS-Client crifan$ git add JianDao/FileManageViewController.swift
licrifandeMacBook-Pro:iOS-Client crifan$ git add JianDao/FileTableViewCell.swift
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
Applying: 1. optimize message table view cell layout -> added text/file/image view and unify all layout
6.git checkout master
7.git merge branch_name
去把rebase后的branch,合并到主分支
-》其实没有任何多余的内容合并,而只是把master的HEAD指向最新的branch的最新的HEAD而已
-》所以叫做fast forward?
8.git push
最终把合并好的master,上传到服务器中
转载请注明:在路上 » [总结]git的rebase的完整过程