我已经阅读并且(我认为)理解了this excellent answer,但是据我所见,它并不能回答我的特定问题(因为它解释了如何基于不同< / em>分支,但我想基于同一分支)。
情况
master
和feature
,feature
有时在master
之上重新建立feature
从master
的先前提交之一中“分支出来” (* * EDIT:原因,例如:将本地feature
分支上的更改重新建立到master
后就中断了,因此请尝试找出,然后提交master
打破了feature
分支,类似于git-bisect
)
问题:如何实现?
插图
如何去做:
G--H--I--J <-- feature
/
A--B--C--D--E--F <-- master
...对此?
G--H--I--J <-- feature
/
A--B--C--D--E--F <-- master
到目前为止的尝试
尝试#1:
git checkout feature
git rebase C
结果:Current branch bug/8985-miniredis is up to date.
不变。
我认为这个结果很合理,因为对于git来说,C
也是“当前分支”的一部分。 (尽管,按照我的观点,“当前分支”只是G..J
)
尝试#2:
git checkout feature
git rebase --onto C feature
结果:First, rewinding head to replay your work on top of it...
。然后feature
仅指向C
,其他提交“丢失”。我真的不明白这里发生了什么,但是从我的角度来看,git再也不知道feature
是从F
开始的。
尝试#3:
git checkout feature
git rebase --onto C master..feature
结果:fatal: invalid upstream 'master..feature'
如该答案的comments中所述,这是不可能的,因为git
会自己插入..HEAD
部分。但是可以肯定,必须有某种方法可以实现这一目标?
换句话说,问题:
如果git rebase --onto C master..feature
有效,如何实现?
答案 0 :(得分:1)
首先,感谢@YesThatIsMyName为我指出正确的方向。
第1.a点。 this answer中的人有我需要的东西。
使用上面的符号,正确的命令如下:
void *B = &A;
printf("%p -- %p -- %s -- %s", (void *)&A, (void *)B, A, *(char **)B);