修复git merge分支到master的冲突

时间:2012-08-07 07:41:16

标签: git version-control github merge branch

如何将此分支合并到master?

thufir@dur:~/NetBeansProjects$ 
thufir@dur:~/NetBeansProjects$ git clone -b 4.GUI_loading_messages_slowly git@github.com:THUFIR/USENET.git
Cloning into USENET...
remote: Counting objects: 3782, done.
remote: Compressing objects: 100% (1274/1274), done.
remote: Total 3782 (delta 1647), reused 3613 (delta 1478)
Receiving objects: 100% (3782/3782), 388.55 KiB | 100 KiB/s, done.
Resolving deltas: 100% (1647/1647), done.
thufir@dur:~/NetBeansProjects$ 
thufir@dur:~/NetBeansProjects$ cd USENET
thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ git branch -a
* 4.GUI_loading_messages_slowly
  remotes/origin/1.FetchBean_CLI
  remotes/origin/2.some_GUI
  remotes/origin/3.messageId__string
  remotes/origin/4.GUI_loading_messages_slowly
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ git checkout -b master remotes/origin/master
Branch master set up to track remote branch master from origin.
Switched to a new branch 'master'
thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ git branch
  4.GUI_loading_messages_slowly
* master
thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ git diff master 4.GUI_loading_messages_slowly 
diff --git a/src/META-INF/persistence.xml b/src/META-INF/persistence.xml
index 252f563..3cebe3d 100644
--- a/src/META-INF/persistence.xml
+++ b/src/META-INF/persistence.xml
@@ -2,8 +2,8 @@
 <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http:/
   <persistence-unit name="USENETPU" transaction-type="RESOURCE_LOCAL">
     <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-    <class>net.bounceme.dur.usenet.database.Article</class>
-    <class>net.bounceme.dur.usenet.database.Headers</class>
+    <class>net.bounceme.dur.usenet.model.Article</class>
+    <class>net.bounceme.dur.usenet.model.Newsgroup</class>
     <properties>
       <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/usenet
       <property name="javax.persistence.jdbc.password" value="password"/>
diff --git a/src/net/bounceme/dur/usenet/controller/ArticleNewsgroup.java b/src/net/bounceme
index b65737a..a9fadd2 100644
--- a/src/net/bounceme/dur/usenet/controller/ArticleNewsgroup.java
+++ b/src/net/bounceme/dur/usenet/controller/ArticleNewsgroup.java
@@ -5,8 +5,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.mail.Message;
 import javax.mail.MessagingException;
-import net.bounceme.dur.usenet.database.Article;
-import net.bounceme.dur.usenet.database.Headers;
+import net.bounceme.dur.usenet.model.Article;
+import net.bounceme.dur.usenet.model.Newsgroup;
 import net.bounceme.dur.usenet.model.Usenet;

thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ git merge 4.GUI_loading_messages_slowly 
Auto-merging src/net/bounceme/dur/usenet/controller/Page.java
CONFLICT (content): Merge conflict in src/net/bounceme/dur/usenet/controller/Page.java
Auto-merging src/net/bounceme/dur/usenet/database/DatabaseUtils.java
CONFLICT (content): Merge conflict in src/net/bounceme/dur/usenet/database/DatabaseUtils.java
Auto-merging src/net/bounceme/dur/usenet/model/Usenet.java
CONFLICT (content): Merge conflict in src/net/bounceme/dur/usenet/model/Usenet.java
Automatic merge failed; fix conflicts and then commit the result.
thufir@dur:~/NetBeansProjects/USENET$ 
thufir@dur:~/NetBeansProjects/USENET$ 

并不是说我想“修复”冲突,而只是用分支取代master。也许是rebase

4 个答案:

答案 0 :(得分:2)

git checkout master
git merge GUI_loading_messages_slowly
git commit
git push

答案 1 :(得分:1)

您始终切换到要修改的分支。因此,首先检查主人是否适合您的情况。 如果您的合并出错了,您可以使用git reset“撤消”您的合并。

答案 2 :(得分:1)

更改为要合并的分支并输入。

git merge branchname

但是你应该首先阅读基础知识和文档。

Tutorials

答案 3 :(得分:0)

合并按宣传方式工作,但仅在删除主分支后才能执行:

thufir@dur:~/NetBeansProjects$ 
thufir@dur:~/NetBeansProjects$ git clone git@github.com:THUFIR/usenet.git
Cloning into usenet...
remote: Counting objects: 3750, done.
remote: Compressing objects: 100% (1263/1263), done.
remote: Total 3750 (delta 1630), reused 3585 (delta 1465)
Receiving objects: 100% (3750/3750), 385.93 KiB | 85 KiB/s, done.
Resolving deltas: 100% (1630/1630), done.
thufir@dur:~/NetBeansProjects$ 
thufir@dur:~/NetBeansProjects$ cd usenet/
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git branch -a
* 4.GUI_loading_messages_slowly
  remotes/origin/1.FetchBean_CLI
  remotes/origin/2.some_GUI
  remotes/origin/3.messageId__string
  remotes/origin/4.GUI_loading_messages_slowly
  remotes/origin/HEAD -> origin/4.GUI_loading_messages_slowly
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git branch master
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git branch
* 4.GUI_loading_messages_slowly
  master
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git checkout master
Switched to branch 'master'
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git branch
  4.GUI_loading_messages_slowly
* master
thufir@dur:~/NetBeansProjects/usenet$ git branch -a
  4.GUI_loading_messages_slowly
* master
  remotes/origin/1.FetchBean_CLI
  remotes/origin/2.some_GUI
  remotes/origin/3.messageId__string
  remotes/origin/4.GUI_loading_messages_slowly
  remotes/origin/HEAD -> origin/4.GUI_loading_messages_slowly
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git merge 4.GUI_loading_messages_slowly 
Already up-to-date.
thufir@dur:~/NetBeansProjects/usenet$ 
thufir@dur:~/NetBeansProjects/usenet$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:THUFIR/usenet.git
 * [new branch]      master -> master
thufir@dur:~/NetBeansProjects/usenet$ 

合并才有效,因为我第一次删除了主分支,这似乎有点极端,但你有。否则,我不知道如何修复冲突,正如精细的手册建议的那样,编辑文件以使它们匹配。我只是不明白合并点,如果你首先必须手动编辑事物,以便它们匹配不同的分支,似乎应该有一个提示,而不是错误信息。

条件是你不能在github上删除带有push origin :master的主分支而不先更改默认分支,这很容易。我发现合并并不总是自动合并有时会加剧,并且有时会反驳说存在冲突。我不明白为什么合并不能退回咨询,然后问“你确定吗?”然后无论如何合并。无论如何,我学到了一些(小)git,特别是如何删除分支。

我不明白Already up-to-date.的含义,我的意思是,github上的起源肯定不是最新的,所以我想知道最新的是什么。据推测,本地副本现在是最新的,但为什么它“已经”更新了?