为什么从另一个分支创建的分支与父分支不同?

时间:2013-03-28 08:15:14

标签: ruby-on-rails git

所以我有一个分支develop,我创建了一个新分支git checkout -b syntax_highlight

问题是,当我去我的新分支时,我的Gemfile在新分支中与父分支不同。

同样,我在后台打开了Gemfile,当我切换分支时,我可以看到它发生了变化。

然而,没有任何进展。

$ git checkout syntax_highlight
Already on 'syntax_highlight'
$ git rebase develop
Current branch syntax_highlight is up to date.
$ git checkout develop
Switched to branch 'develop'
$ git checkout syntax_highlight
Switched to branch 'syntax_highlight'
$ git checkout develop
Switched to branch 'develop'
$ git status
# On branch develop
nothing to commit (working directory clean)
$ git checkout syntax_highlight
Switched to branch 'syntax_highlight'
$ git status
# On branch syntax_highlight
nothing to commit (working directory clean)

对于我的生活,我无法弄清楚为什么我的Gemfile存在差异,这让我想知道git是否还有其他差异没有告诉我。

修改1

在两个分支上运行git log之后,你会看到两者都有相同的提交,除了syntax_highlight分支最近有1个提交 - 这是有意义的,因为那就是分支我目前正在努力。

$ git log
commit a0b320a001cb24f42e2cf0f3dfee38cfd53e2290
Author: marcamillion
Date:   Thu Mar 28 02:27:08 2013 -0500

    Got the HABTM counter_cache working.

commit 64b73338c34259f02daa2ed943bd5d47ac5bacc0
Author: marcamillion
Date:   Mon Mar 25 03:16:43 2013 -0500

    Added the basic sidebar layout.

commit 7989813e9a379e480500f12ee01367967b791cd4
Author: marcamillion
Date:   Sun Mar 24 14:36:33 2013 -0500

    Got the basics of the sidebar layout, along with the navigational bar listing useful tags.

commit 1f0feea2f6db36e5c89aaf83c51cfc3b4bdbf01f
Author: marcamillion
Date:   Sun Mar 24 02:48:20 2013 -0500

    Installed bullet gem.


##

$ git checkout syntax_highlight
Switched to branch 'syntax_highlight'
$ git log
commit cccc5cd3350dbcd751e1ceccd0d4865948fd6993
Author: marcamillion
Date:   Thu Mar 28 03:02:20 2013 -0500

    Installed pygments, but haven't been able to test successfully yet.

commit a0b320a001cb24f42e2cf0f3dfee38cfd53e2290
Author: marcamillion
Date:   Thu Mar 28 02:27:08 2013 -0500

    Got the HABTM counter_cache working.

commit 64b73338c34259f02daa2ed943bd5d47ac5bacc0
Author: marcamillion
Date:   Mon Mar 25 03:16:43 2013 -0500

    Added the basic sidebar layout.

commit 7989813e9a379e480500f12ee01367967b791cd4
Author: marcamillion
Date:   Sun Mar 24 14:36:33 2013 -0500

    Got the basics of the sidebar layout, along with the navigational bar listing useful tags.

commit 1f0feea2f6db36e5c89aaf83c51cfc3b4bdbf01f
Author: marcamillion
Date:   Sun Mar 24 02:48:20 2013 -0500

    Installed bullet gem.

修改2

这是git diff具体的结果:

$ git diff-tree --no-commit-id --name-only -r cccc5cd3350dbcd751e1ceccd0d4865948fd6993
Gemfile
Gemfile.lock
app/assets/stylesheets/pygments.css.erb
app/views/home/index.html.erb

2 个答案:

答案 0 :(得分:1)

我不知道你为什么期望它是相同的(除非你确定你从未提交过该文件)。你能在两个分支上运行git log吗?

答案 1 :(得分:0)

您对cccc5cd3350dbcd751e1ceccd0d4865948fd6993的提交已经更新了Gemfile ...所以希望看到您的Gemfile更新...当您重新开发开发时,您只需在开发(无)的任何更改之上重新应用您的提交。你的syntax_highlight分支上唯一的变化就是上面的提交更新了Gemfile。这有意义吗?