尽管有变化

时间:2016-04-29 11:29:17

标签: git github branching-and-merging

我正在使用git在项目上进行协作。有一个主存储库,然后我们每个都有自己的分支,并从master中将更改提取到它们中。然而,尽管事实上我可以看到我的分支中没有主人的变化,但我不能让他们把它们带进去:

$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

(master) $ git status
On branch master
Your branch is up-to-date with 'origin/master'.

## removed listing of untracked files not relevant to the question ##

nothing added to commit but untracked files present (use "git add" to track)

因此,我的本地master分支与远程master保持同步。请注意,我还有未跟踪的文件,这些文件列在git status的输出中。我删除了这些行,因为它们在这里不相关。

现在,我切换到我的terdon分支:

(master) $ git checkout terdon
Switched to branch 'terdon'
Your branch is up-to-date with 'origin/terdon'.

(master) $ git status
On branch terdon
Your branch is up-to-date with 'origin/master'.

## removed listing of untracked files not relevant to the question ##

nothing added to commit but untracked files present (use "git add" to track)

如上所述,分支是最新的,远程terdonstatus确认它。但是,master中的更改不在terdon中:

(terdon) $ git diff terdon master | wc 
   1940    8389   77113  ## loads of differences

试图拉它们但是不起作用:

(terdon) $ git pull origin master
From github.com:foo/foo
 * branch            master     -> FETCH_HEAD
Already up-to-date.

(terdon) $ git merge master 
Already up-to-date.

我确实注意到master中的最新提交也在terdon中,但是:

$ git log origin/terdon --graph
* commit 800a899fbb88ac16d1856f6d199ffba7817fba6b
| Author: terdon
| Date:   Fri Apr 29 13:09:56 2016 +0200
| 
|     use local tmp dir and allow 12G mem for novosort
|    
*   commit d8c90a8a53ba803be8a5593c4470eed4ac9b6e40
|\  Merge: 7635f22 46edf86
| | Author: terdon
| | Date:   Fri Apr 29 13:03:08 2016 +0200
| | 
| |     Merge branch 'master' of github.com:foo/foo into terdon
| |   
| * commit 46edf86e2329f9351bff291eeb55e8cb13f70031
| | Author: Andreas
| | Date:   Fri Apr 29 09:37:47 2016 +0200
| | 
| |     bug fix with new transcriptomes not having pointer to reference genome
| |     

$ git log origin/master --graph | head
* commit 46edf86e2329f9351bff291eeb55e8cb13f70031
| Author: Andreas
| Date:   Fri Apr 29 09:37:47 2016 +0200
| 
|     bug fix with new transcriptomes not having pointer to reference genome
|    

这让我觉得我做了一些愚蠢的事情,但我无法弄清楚是什么。如何将master分支中我知道的更改带入terdon

我也尝试了Code Wizard's answer的建议,但没有变化:

$ git fetch --all --prune
Fetching origin
From github.com:foo/branch2
 x [deleted]         (none)     -> origin/branch3
 x [deleted]         (none)     -> origin/branch4
 x [deleted]         (none)     -> origin/branch5
 x [deleted]         (none)     -> origin/branch6
 x [deleted]         (none)     -> origin/branch7
 x [deleted]         (none)     -> origin/branch8
 x [deleted]         (none)     -> origin/branch9
 x [deleted]         (none)     -> origin/branch10
 x [deleted]         (none)     -> origin/branch11
 x [deleted]         (none)     -> origin/branch12
 x [deleted]         (none)     -> origin/branch13
 x [deleted]         (none)     -> origin/branch14
 x [deleted]         (none)     -> origin/branch15
 x [deleted]         (none)     -> origin/branch16
 x [deleted]         (none)     -> origin/branch17
 x [deleted]         (none)     -> origin/branch18
 x [deleted]         (none)     -> origin/branch19
 x [deleted]         (none)     -> origin/branch20
 x [deleted]         (none)     -> origin/branch21
 x [deleted]         (none)     -> origin/branch22
 x [deleted]         (none)     -> origin/branch23
然后我跑了:

$ git log master ^terdon 

$ git log ^terdon master

但是没有输出。

1 个答案:

答案 0 :(得分:2)

快速回答:

您在terdon分支中有更改但尚未掌握。

<强> More details

首先做一个完整的git fetch(不会改变任何东西,但最好更新)

git fetch --all --prune

其次看起来你所有的更改都是在terdon分支而不是master上进行的,所以你的terdon分支已经用master更新了(它是master假设的分支)。

要验证这是实际情况,请结帐master并与terdon

进行“干”合并
git log ^master terdon
OR
git log master ^terdon

取决于您所在的分支以及是否要查看拉/推更改。

<强> A Full answer

  

git diff <branch> <branch>

git diff <branch> <branch>显示您的两个分支之间的更改。看起来您已经提交tredon但未合并到主人。您的主人是最新的,更改在新分支。

<强> How to merge the changes?

git checkout master
git merge tredon