0

如何将此分支合并到主分支?

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 替换为分支。也许变基

4

4 回答 4

2
git checkout master
git merge GUI_loading_messages_slowly
git commit
git push
于 2012-08-07T07:44:57.257 回答
1

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

于 2012-08-07T07:44:52.430 回答
1

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

git merge branchname

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

教程

于 2012-08-07T07:45:40.283 回答
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$ 

合并之所以有效,是因为我首先删除了 master 分支,这似乎有点极端,但你就是这样。否则,我不确定如何解决冲突,而无需按照精美手册的建议编辑文件以使其匹配。如果您首先必须手动编辑内容以使其与不同的分支匹配,我只是不明白合并的意义,似乎应该有一个提示,而不是错误消息。

附带条件是,如果push origin :master不先更改默认分支,就不能在 github 上删除 master 分支,这很容易。我发现合并并不总是自动合并,有时会抱怨存在冲突,这有点令人恼火。我不明白为什么合并不能返回咨询,然后问“你确定吗?” 然后无论如何合并。无论如何,我学到了一点关于 git 的知识,特别是如何删除一个分支。

我不明白 的意思Already up-to-date.,我的意思是,github 上的 origin 肯定不是最新的,所以我想知道什么是最新的。大概本地副本现在是最新的,但为什么它“已经”是最新的?

于 2012-08-09T08:49:05.257 回答