以下命令之间有什么区别?:
git diff foo master # a
git diff foo..master # b
git diff foo...master # c
Run Code Online (Sandbox Code Playgroud)
diff手册谈到它:
比较分支机构
Run Code Online (Sandbox Code Playgroud)$ git diff topic master <1> $ git diff topic..master <2> $ git diff topic...master <3>
- 主题提示与主分支之间的更改.
- 与上述相同.
- 自主题分支启动以来主分支上发生的更改.
但对我来说并不完全清楚.
git rebase
在保留提交时间戳的同时执行是否有意义?
我相信结果是新分支不一定按时间顺序排列日期.这在理论上是否可行?(例如使用管道命令;只是好奇这里)
如果理论上可行,那么在实践中是否可以使用rebase,而不是更改时间戳?
例如,假设我有以下树:
master <jun 2010>
|
:
:
: oldbranch <feb 1984>
: /
oldcommit <jan 1984>
Run Code Online (Sandbox Code Playgroud)
现在,如果我重新oldbranch
启动master
,则提交日期将从1984年2月更改为2010年6月.是否可以更改该行为以便不更改提交时间戳?最后我会得到:
oldbranch <feb 1984>
/
master <jun 2010>
|
:
Run Code Online (Sandbox Code Playgroud)
那会有意义吗?甚至允许在git中有一个旧提交最近提交作为父项的历史记录?
当我开始时git rebase -i
,我可以发出像git rebase --continue
或的命令git rebase --abort
.这些命令仅在rebase正在进行时才有效.
我如何知道是否有正在进行的改造?
(我非常感谢关于rebase如何在内部工作的一些细节; git对一个repo做了什么,使它具有"rebase in progress"状态,?)
给定一个冲突的文件foo.txt
,如何告诉git diff
显示文件的基本版本和文件的"他们的"版本之间的变化?
我可以通过git show :1:foo.txt
或看到每个版本git show:3:foo.txt
- 是否有一种比较两个版本的简单方法?
当处于交互式rebase的中间时,例如git rebase -i HEAD~12
添加/编辑一些提交时,我常常对我正在编辑的提交感到困惑,特别是当存在合并冲突时:
> git status
rebase in progress; onto 55d9292
You are currently rebasing branch 'master' on '55d9292'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: file
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
如何清楚了解当前状态中涉及的所有补丁?例如,什么是基本补丁,我正在"挑选"哪个补丁,合并冲突来自哪个补丁?
当我做git rebase master时,有时会发生冲突。有时即使出现错误消息也很难追踪问题。如果我能找出哪个提交git试图重新应用并引起冲突,那将是一个真正的帮助。
我如何找出导致冲突的提交?
鉴于以下(有点人为的)情况 - 3 次提交及其提交消息,其中我在我的原点/主控之前 2 次提交并且想要重新设定基准:
C1 <-- origin/master
first commit
* Implement the foo
C2
second commit
* Wibble the foo
* This is temporary to workaround the issue with the thingy, and can be removed after Steve applies his fix.
C3 <-- HEAD
third commit
* Add the wotsit
Run Code Online (Sandbox Code Playgroud)
随着C3
检出的,我做的事:git rebase origin/master
和我们说有冲突,所以我看到的是这样的:
First, rewinding head to replay your work on top of it...
Applying: second commit
Using index info to reconstruct a base tree... …
Run Code Online (Sandbox Code Playgroud)