【发布时间】:2015-11-26 21:00:48
【问题描述】:
我的分支中有以下提交
$ git log --pretty=oneline
aa2ea957db6bf5f097b0e2f046c4c3f76758c6d9 Merge branch 'CentralCache_Stats' of gi ==> When I pull from master it create new commit don't why ?
4ece4416421334e8be75893ef1416bb8509d2a44 [744] New API for central cache informa ==> I make changes and did commit --amend then also it create new commit.
a49d7ef9f2e0c7adedb8dee96f79ce1d9e2855db Merge branch 'master' of github.com:gsh ==> When I pull from master it create new commit don't why ?
b632ef35f7776e365e36b508d8e490b429646317 [744] New API for central cache informa ==> I make changes and forgot to add commit --amend
a8c54056cb3012fb8da7221b419857422b168046 [744] New API for central cache informa ==> I make come change
64892ae730b704a7f3f23bd8eaeaf206901df201 lower default transfer batch size down ==> This is master change
现在我想将我的所有提交合并为一个。
$ git log --oneline --graph --decorate
* aa2ea95 (HEAD, CentralCache_Stats) Merge branch 'CentralCache_Stats' of githu
|\
| * a49d7ef (origin/CentralCache_Stats) Merge branch 'master' of github.com:gsh
| |\
| | * a8c5405 (origin/master, origin/HEAD, master) [744] New API for central cach
| * | b632ef3 [744] New API for central cache information
| |/
* | 4ece441 [744] New API for central cache information
|/
* 64892ae lower default transfer batch size down to 512
Ahhh such a mess
一个解决方案是我通过 git reset HEAD^n 返回并提交 --amend,但问题是我更改了很多代码,因此解决冲突将是个问题
我试过了
git rebase
s aa2ea957db6bf5f097b0e2f046c4c3f76758c6d9 Merge branch 'CentralCache_Stats' of gi
p 4ece4416421334e8be75893ef1416bb8509d2a44 [744] New API for central cache informa
p a49d7ef9f2e0c7adedb8dee96f79ce1d9e2855db Merge branch 'master' of github.com:gsh
p b632ef35f7776e365e36b508d8e490b429646317 [744] New API for central cache informa
p a8c54056cb3012fb8da7221b419857422b168046 [744] New API for central cache informa
p 64892ae730b704a7f3f23bd8eaeaf206901df201 lower default transfer batch size down
如果没有先前的提交,我收到错误无法压缩
git log
commit 6bf5f097b0e2f046c4c3f76758c6d9
Merge: 4ece441 a49d7ef
....
commit 4ece4416421334e8be75893ef1416bb8509d2a44
....
commit a49d7ef9f2e0c7adedb8dee96f79ce1d9e2855db
Merge: b632ef3 a8c5405
....
commit b632ef35f7776e365e36b508d8e490b429646317
....
commit a8c54056cb3012fb8da7221b419857422b168046
....
commit 64892ae730b704a7f3f23bd8eaeaf206901df201
....
如何合并或解决这个问题?
【问题讨论】:
-
为什么要这样做?真的是那么乱吗?
git log --oneline --graph --decorate说什么? -
@Makoto 添加了问题。
-
git reset HEAD~2 --mixed和git commit怎么样?
标签: git merge git-merge git-rebase