最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[记录]Xcode 中git merge branch合并分支到master主干上

Git crifan 6338浏览 0评论

试试:

以及:

Merge Into Branch

[已解决]Xcode中merge失败:error Your local changes to the following files would be overwritten by merge UserInterfaceState.xcuserstate

此时,已经可以继续操作了:

算了,不去这么操作了。

因为想到了:

当前branch去merge到master中,

会导致:

之前此branch中的commit都看不到了。

所以还是优先考虑去rebase

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch v1.0 is up to date.
licrifandeMacBook-Pro:iOS-Client crifan$

好需要把本地的master上传到服务器上?

去试试:

或者去切换到master??

去试试push

然后选择push到

origin/master上:

然后就push成功了。

但是去看,结果本地还是brach v1.0

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch v1.0 is up to date.
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch v1.0
Your branch is ahead of ‘origin/v1.0’ by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
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: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 366 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
   a3ebc17..691220d  v1.0 -> v1.0
licrifandeMacBook-Pro:iOS-Client crifan$
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 status
On branch master
Your branch is up-to-date with ‘origin/master’.
Changes not staged for commit:
  (use "git add <file>…" to update what will be committed)
  (use "git checkout — <file>…" to discard changes in working directory)
modified:   JianDao/.DS_Store
modified:   JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
Untracked files:
  (use "git add <file>…" to include in what will be committed)
JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/WorkspaceSettings.xcsettings
JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcdebugger/
no changes added to commit (use "git add" and/or "git commit -a")
licrifandeMacBook-Pro:iOS-Client crifan$

然后重新切换回道v1.0,然后再去rebase:

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
First, rewinding head to replay your work on top of it…
Applying: hide the file and favorite tab
Using index info to reconstruct a base tree…
A JianDao/.DS_Store
A JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
<stdin>:31: trailing whitespace.
//           
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge…
error: refusing to lose untracked file at ‘JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate’
error: refusing to lose untracked file at ‘JianDao/.DS_Store’
CONFLICT (modify/delete): JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate deleted in 68ff532a1596b5ee57d8442294e084ee62b894da and modified in hide the file and favorite tab. Version hide the file and favorite tab of JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate left in tree.
CONFLICT (modify/delete): JianDao/.DS_Store deleted in 68ff532a1596b5ee57d8442294e084ee62b894da and modified in hide the file and favorite tab. Version hide the file and favorite tab of JianDao/.DS_Store left in tree.
Failed to merge in the changes.
Patch failed at 0001 hide the file and favorite tab
The copy of the patch that failed is found in:
   /Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client/.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".
licrifandeMacBook-Pro:iOS-Client crifan$

搜:

git rebase The copy of the patch that failed is found in

2013.12.31 ——— git学习之解决冲突 – 学习是一种信仰 – ITeye技术网站

git rebase 如何解决冲突

Git下的冲突解决 – sinojelly – 博客园

Git使用之——冲突解决一(git merge conflict) – younghz – 博客频道 – CSDN.NET

对于解决 Git 的 Merge Conflict 你有哪些经验和技巧? – 知乎

搜:

git rebase error refusing to lose untracked file at

git  error refusing to lose untracked file at

git merge fails refusing to lose untracked file – Stack Overflow

去删除试试:

licrifandeMacBook-Pro:iOS-Client crifan$ git rm –cached *UserInterfaceState.xcuserstate
JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
rm ‘JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate’
rm ‘JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate’
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
JianDao/.DS_Store: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

搜:

git  rm needs merge

Resolving a merge conflict from the command line – User Documentation

Git下的冲突解决 – sinojelly – 博客园

Git Merge Conflict – Remote File Deleted, Local File Changed – Stack Overflow

好像是需要:

再去git commit:

licrifandeMacBook-Pro:iOS-Client crifan$ git commit
U JianDao/.DS_Store
error: commit is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use ‘git add/rm <file>’
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
licrifandeMacBook-Pro:iOS-Client crifan$ git rm –cached *UserInterfaceState.xcuserstate
fatal: pathspec ‘*UserInterfaceState.xcuserstate’ did not match any files
licrifandeMacBook-Pro:iOS-Client crifan$ git commit
licrifandeMacBook-Pro:iOS-Client crifan$ git rm –cached *UserInterfaceState.xcuserstate
fatal: pathspec ‘*UserInterfaceState.xcuserstate’ did not match any files
licrifandeMacBook-Pro:iOS-Client crifan$ git rm  *UserInterfaceState.xcuserstate
fatal: pathspec ‘*UserInterfaceState.xcuserstate’ did not match any files
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
JianDao/.DS_Store: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
licrifandeMacBook-Pro:iOS-Client crifan$

搜:

error commit is not possible because you have unmerged files

GIT merge error "commit is not possible because you have unmerged files" – Stack Overflow

licrifandeMacBook-Pro:iOS-Client crifan$ git add *.DS_Store
licrifandeMacBook-Pro:iOS-Client crifan$ git commit
Aborting commit due to empty commit message.
licrifandeMacBook-Pro:iOS-Client crifan$ git commit -m "remove? untracked file"
[detached HEAD ce21e76] remove? untracked file
 6 files changed, 22 insertions(+), 22 deletions(-)
 create mode 100644 JianDao/.DS_Store
licrifandeMacBook-Pro:iOS-Client crifan$ 
licrifandeMacBook-Pro:iOS-Client crifan$ git status
rebase in progress; onto 68ff532
You are currently rebasing branch ‘v1.0′ on ’68ff532’.
  (all conflicts fixed: run "git rebase –continue")
nothing to commit, working directory clean
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –continue
Applying: hide the file and favorite tab
No changes – did you forget to use ‘git add’?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this 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".

算了,放弃:

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase –abort

结果后来还是不行:

licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.
Changes not staged for commit:
  (use "git add <file>…" to update what will be committed)
  (use "git checkout — <file>…" to discard changes in working directory)
modified:   JianDao/.DS_Store
Untracked files:
  (use "git add <file>…" to include in what will be committed)
JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/WorkspaceSettings.xcsettings
JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcdebugger/
no changes added to commit (use "git add" and/or "git commit -a")
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout v1.0
error: Your local changes to the following files would be overwritten by checkout:
JianDao/.DS_Store
Please, commit your changes or stash them before you can switch branches.
Aborting
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout — JianDao/.DS_Store
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch master
Your branch is up-to-date with ‘origin/master’.
Untracked files:
  (use "git add <file>…" to include in what will be committed)
JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/WorkspaceSettings.xcsettings
JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcdebugger/
nothing added to commit but untracked files present (use "git add" to track)
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout v1.0
Switched to branch ‘v1.0’
Your branch is up-to-date with ‘origin/v1.0’.
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch v1.0 is up to date.
licrifandeMacBook-Pro:iOS-Client crifan$

搜:

git rebase Current branch is up to date

git rebase nothing to do

其实已经是OK的了:

(当前是branch v1.0去执行)git rebase master

结果啥都没做:

Current branch v1.0 is up to date.

-》其实表示:

此处的brach,已经是从mastre上面的分支分出来的

直到现在,master上面,也没有其他更新

所以无需执行其他动作,已经OK了。

接下来要做的事情,就是:

切换到master中

然后把branch v1.0中的改动都merge过来到master中

然后master中再去push就可以了。

具体步骤如下(其中部分内容是处理一些忽略的文件):

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch v1.0 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 v1.0
Updating b5ffa39..691220d
error: Your local changes to the following files would be overwritten by merge:
JianDao/.DS_Store
JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
Please, commit your changes or stash them before you can merge.
Aborting
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout — *.DS_Store
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout — *UserInterfaceState.xcuserstate
licrifandeMacBook-Pro:iOS-Client crifan$ git merge v1.0
Updating b5ffa39..691220d
error: Your local changes to the following files would be overwritten by merge:
JianDao/.DS_Store
Please, commit your changes or stash them before you can merge.
Aborting
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout — *.DS_Store
licrifandeMacBook-Pro:iOS-Client crifan$ git merge v1.0
Updating b5ffa39..691220d
Fast-forward
 .DS_Store                                                                    | Bin 10244 -> 0 bytes
 .gitignore                                                                   |   5 +
 JianDao/.DS_Store                                                            | Bin 16388 -> 0 bytes
 JianDao/AddMoreView.swift                                                    |  28 +
 JianDao/ChangePasswordViewController.swift                                   | 240 ++++++++++++
 JianDao/ContactItemTableViewCell.swift                                       |  43 ++
 JianDao/ContactTableViewData.swift                                           |  92 +++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 JianDao/ContactUtility.swift                                                 | 103 ++++
 JianDao/ContactViewController.swift                                          |  20 +
 JianDao/Conversation.swift                                                   | 118 +++++
 JianDao/ConversationManageViewController.swift                               |   5 +
 JianDao/ConversationUtility.swift                                            |   4 +
 JianDao/ConversationViewController.swift                                     | 726 +++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<———————
 JianDao/CreateGroupTopicViewController.swift                                 |  36 +
 JianDao/CrifanLib.swift                                                      |  45 +++
 JianDao/EditInfoViewController.swift                                         |  14 +
 JianDao/FileBubbleView.swift                                                 |   2 +
 JianDao/FileManageViewController.swift                                       |   3 +
 JianDao/FileViewController.swift                                             | 119 +++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<-
 JianDao/GlobalClasses.swift                                                  |   4 +
 JianDao/GlobalFunctions.swift                                                |  13 +
 JianDao/GlobalValues.swift                                                   |   8 +
 JianDao/GroupTopicTableViewController.swift                                  |  88 ++++
 JianDao/Image.swift                                                          | 329 ++++++++++++++++
 JianDao/ImageBubbleView.swift                                                |  96 +++++
 JianDao/ImageCache.swift                                                     | 647 ++++++++++++++++++++++++++++++++
 JianDao/ImageDownloader.swift                                                | 443 ++++++++++++++++++++++
 JianDao/ImageTransition.swift                                                | 123 ++++++
 JianDao/ImageView+Kingfisher.swift                                           | 423 +++++++++++++++++++++
 JianDao/JianDao.xcodeproj/project.pbxproj                                    |  70 ++++
 …/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate             | Bin 497052 -> 0 bytes
 JianDao/JianDao/.DS_Store                                                    | Bin 8196 -> 0 bytes
 JianDao/JianDao/Constants.swift                                              |   9 +
 JianDao/Kingfisher.h                                                         |  37 ++
 JianDao/KingfisherManager.swift                                              | 224 +++++++++++
 JianDao/KingfisherOptionsInfo.swift                                          | 160 ++++++++
 JianDao/LoginViewController.swift                                            | 131 ++++++
 JianDao/MainViewController.swift                                             |  58 +<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 JianDao/Message.swift                                                        | 223 +++++++++++
 JianDao/MessageTableViewCell.swift                                           |  96 +++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 JianDao/MessageTableViewController.swift                                     | 561 +++++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<———–
 JianDao/MessageUtility.swift                                                 |  41 +
 JianDao/RegisterPhoneViewController.swift                                    | 476 +++++++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<—-
 JianDao/RegisterUsernameViewController.swift                                 |  14 +
 JianDao/Resource.swift                                                       |  54 +++
 JianDao/ResourceUtility.swift                                                | 336 ++++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<-
 JianDao/SelfInfoViewController.swift                                         |  12 +
 JianDao/SendInvitationViewController.swift                                   |   7 +
 JianDao/String+MD5.swift                                                     | 266 +++++++++++++
 JianDao/TeamTableViewData.swift                                              |   2 +
 JianDao/ThreadHelper.swift                                                   |  44 +++
 JianDao/UIButton+Kingfisher.swift                                            | 607 ++++++++++++++++++++++++++++++
 52 files changed, 5995 insertions(+), 1210 deletions(-)
 delete mode 100644 .DS_Store
 create mode 100644 .gitignore
 delete mode 100644 JianDao/.DS_Store
 create mode 100644 JianDao/ChangePasswordViewController.swift
 create mode 100755 JianDao/Image.swift
 create mode 100644 JianDao/ImageBubbleView.swift
 create mode 100755 JianDao/ImageCache.swift
 create mode 100755 JianDao/ImageDownloader.swift
 create mode 100755 JianDao/ImageTransition.swift
 create mode 100755 JianDao/ImageView+Kingfisher.swift
 delete mode 100644 JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
 delete mode 100644 JianDao/JianDao/.DS_Store
 create mode 100755 JianDao/Kingfisher.h
 create mode 100755 JianDao/KingfisherManager.swift
 create mode 100755 JianDao/KingfisherOptionsInfo.swift
 create mode 100755 JianDao/Resource.swift
 create mode 100755 JianDao/String+MD5.swift
 create mode 100755 JianDao/ThreadHelper.swift
 create mode 100755 JianDao/UIButton+Kingfisher.swift
licrifandeMacBook-Pro:iOS-Client crifan$ 

再去Xcode中,就可以看到:

1.当前是master了:

2.当前的历史记录中也已经是最新的(branch v1.0)中的最新的内容了:

然后再去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)
Total 0 (delta 0), reused 0 (delta 0)
   b5ffa39..691220d  master -> master
licrifandeMacBook-Pro:iOS-Client crifan$

然后去OSChina上看git日志图形效果,master和v1.0也都是最新的了:

再记录一次过程:

已经在branch中,修改了代码,测试无误。

然后terminal中看看:

licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch image_preview
Changes to be committed:
  (use "git reset HEAD <file>…" to unstage)
new file:   JianDao/ImageViewController.swift
Changes not staged for commit:
  (use "git add <file>…" to update what will be committed)
  (use "git checkout — <file>…" to discard changes in working directory)
modified:   JianDao/ImageBubbleView.swift
modified:   JianDao/ImageViewController.swift
modified:   JianDao/JianDao.xcodeproj/project.pbxproj
modified:   JianDao/MessageTableViewController.swift
licrifandeMacBook-Pro:iOS-Client crifan$ git branch
* image_preview
  master
  v1.0
licrifandeMacBook-Pro:iOS-Client crifan$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
    git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
    git branch –set-upstream-to=origin/<branch> image_preview
licrifandeMacBook-Pro:iOS-Client crifan$ git pull origin image_preview
fatal: Couldn’t find remote ref image_preview
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Cannot rebase: You have unstaged changes.
Additionally, your index contains uncommitted changes.
Please commit or stash them.

然后去Xcode中用Git的commit(只是commit到本地,没有push到远端到当前分支image_privew)

之后再去terminal中:

licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch image_preview 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 pull
Already up-to-date.
licrifandeMacBook-Pro:iOS-Client crifan$ git merge image_preview
Updating 691220d..ef82130
Fast-forward
 JianDao/ImageBubbleView.swift             |   4 ++
 JianDao/ImageViewController.swift         | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 JianDao/JianDao.xcodeproj/project.pbxproj |  17 ++++++
 JianDao/MessageTableViewController.swift  |  58 ++++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<——–
 4 files changed, 229 insertions(+), 24 deletions(-)
 create mode 100644 JianDao/ImageViewController.swift
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: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 11.94 KiB | 0 bytes/s, done.
Total 8 (delta 3), reused 0 (delta 0)
   691220d..ef82130  master -> master
licrifandeMacBook-Pro:iOS-Client crifan$

然后再去网页端看看日志历史:

然后再去打个tag:

licrifandeMacBook-Pro:iOS-Client crifan$ git tag
v0.8
licrifandeMacBook-Pro:iOS-Client crifan$ git tag -a image_preview -m "support image preview: loaded image can show small preview and click loaded image to open see full image, pinch to zomm and double click to zoom in and single click to quit"
licrifandeMacBook-Pro:iOS-Client crifan$ git tag
image_preview
v0.8
licrifandeMacBook-Pro:iOS-Client crifan$

再去参考:

Git – 打标签

把本地标签上传到远端:

licrifandeMacBook-Pro:iOS-Client crifan$ git push origin –tags
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 368 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
 * [new tag]         image_preview -> image_preview
 * [new tag]         v0.8 -> v0.8
licrifandeMacBook-Pro:iOS-Client crifan$ 

然后远端可以看到了:

再次纪录过程:

Xcode中,改好了代码后,去commit到local的branch:fixbug_websocket_connect中

然后再去:

licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch fixbug_websocket_connect
nothing to commit, working directory clean
licrifandeMacBook-Pro:iOS-Client crifan$ git rebase master
Current branch fixbug_websocket_connect 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 fixbug_websocket_connect
Updating ef82130..fe61331
Fast-forward
 JianDao/GlobalClasses.swift               |  7 ++++++
 JianDao/JianDao.xcodeproj/project.pbxproj |  5 ++++
 JianDao/JianDao/AppDelegate.swift         | 19 ++++++++++++++
 JianDao/JianDao/Constants.swift           |  5 ++++
 JianDao/JianDao/Info.plist                |  8 +++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 JianDao/LoginViewController.swift         | 72 ++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<————————————————-
 JianDao/MainViewController.swift          | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 JianDao/MyViewController.swift            |  2 ++
 JianDao/NetworkUtility.swift              |  2 <span style="font: 11.0px Menlo; font-variant-ligatures: no-common-ligatures; color: #c33720;"–<
 9 files changed, 138 insertions(+), 75 deletions(-)
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: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 9.48 KiB | 0 bytes/s, done.
Total 14 (delta 8), reused 0 (delta 0)
   ef82130..fe61331  master -> master
licrifandeMacBook-Pro:iOS-Client crifan$

这次应该是正常的流程:

1.branch中,git commit到本地的branch

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 origin master

licrifandeMacBook-Pro:iOS-Client crifan$ git pull origin master
 * branch            master     -> FETCH_HEAD
Already up-to-date.
licrifandeMacBook-Pro:iOS-Client crifan$ 

4.中间应该是:

切换到branch:

git checkout branch

然后再去

git rebase master

git checkout master

然后再去做下面的

4.git merge branch_name

licrifandeMacBook-Pro:iOS-Client crifan$ git merge update_ui
Updating fe61331..6fa4262
Fast-forward
 JianDao/ContactItemTableViewCell.swift                                       |  46 ++
 JianDao/ConversationManageViewController.swift                               |   …

5.git pull

[总结]

基本流程:

当前已经在branch中,commit了最新的改动了:

1.处在branch中

git rebase master

输出:

Current branch v1.0 is up to date.

2.切换到master中:

git checkout master

输出:

Switched to branch ‘master’
Your branch is up-to-date with ‘origin/master’.

3.将branch的东西合并到master:

git merge v1.0

输出:

Updating b5ffa39..691220d
Fast-forward

4.将本地master上传推送到远端服务器的master:

git push

输出:

。。。
Total 0 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/windoze/iOS-Client.git
   b5ffa39..691220d  master -> master

转载请注明:在路上 » [记录]Xcode 中git merge branch合并分支到master主干上

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.210 seconds, using 22.21MB memory