我想在主分支上对一个分支进行变基,但要以这样一种方式使得所有提交以时间顺序在git日志中显示。是否可以在不使用git rebase --interactive
并手动重新排列提交的情况下实现?
背景:我正在使用git跟踪服务器群的puppet配置。主分支始终处于已知的良好状态,因此所有现有服务器都可以从puppet主服务器检索其配置。
每个新服务器都有自己的分支,因此每当我处理新服务器的配置时,例如更改域名、配置SSL证书,我都会检出其分支并提交所有配置。
完成新配置后,我会将更改变基到主分支上:
# git checkout new_config
Switched to branch 'new_config'
# git rebase master
First, rewinding head to replay your work on top of it...
Applying: fix routing rules
Applying: fix netmask
Applying: configure new ip address
# git checkout master
Switched to branch 'master'
# git merge new_config
Updating 21a3120..b0b79d7
Fast-forward
files/custom/xxxx | 45 +++++++++++++++++++++++++++++++++++++++++++++
files/custom/yyyy | 38 --------------------------------------
manifests/site.pp | 6 +++---
3 files changed, 48 insertions(+), 41 deletions(-)
#
新提交的内容现在在日志的顶部,但是它们具有它们原来(过去)的日期。它看起来像这样:The new commits are now on top of the log but they have their original (past) dates. It looks like this:
commit b0b79d7924ec97e367664ccc26aaf0021916a30d
Author:
Date: Sun Jul 12 17:14:41 2015 +0200
configure new ip address
commit f60d00abd57d6b8582f49bf1322efb88d44ee86e
Author:
Date: Fri Jul 10 13:19:45 2015 +0200
fix netmask
commit 6eaae6c328faf55e5725f65a947bbb23ea29b166
Author:
Date: Fri Jun 12 14:05:25 2015 +0200
fix routing rules
commit 21a31200e6694c640b2cb526d773af11cd703ff1
Author:
Date: Wed Jul 15 15:08:41 2015 +0200
(most recent commit on master before rebase)
commit a7fa9cfa9c317fbbeb7dac8a89009c7d935fdd11
Author:
Date: Wed Jul 15 11:56:59 2015 +0200
(second most recent commit on master)
注意旧的分支提交的时间戳显示在日志顶部,而不是根据它们的提交日期在日志中进一步合并。我必须运行另一个git rebase --interactive
来重新排列提交,以便我的日志文件按时间顺序显示所有提交。