2

I have following commit's in my branch

$ 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

Now I want to merge all my commit in one.

$ 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

One solution is I got back by git reset HEAD^n and do commit --amend, but the problem I have change lot of code so solving conflicts will be problem

I tried doing

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 

I am getting error cannot squash without previous commit

git log
commit 6bf5f097b0e2f046c4c3f76758c6d9
Merge: 4ece441 a49d7ef
....

commit 4ece4416421334e8be75893ef1416bb8509d2a44
....

commit a49d7ef9f2e0c7adedb8dee96f79ce1d9e2855db
Merge: b632ef3 a8c5405
....

commit b632ef35f7776e365e36b508d8e490b429646317
....

commit a8c54056cb3012fb8da7221b419857422b168046
....

commit 64892ae730b704a7f3f23bd8eaeaf206901df201
....

How to merge or solve this problem ?

SevenEleven
  • 2,326
  • 2
  • 32
  • 32
eswaat
  • 733
  • 1
  • 13
  • 31

1 Answers1

0

You only have to care about the commits in, let's say, your master-branch. If your history, for example, looks like this, with your HEAD on I

master   A---B---H-------I
              \         /  
branch1        C---E---G
                \     /
branch2          D---F

Then you can do git reset A --mixed where A would be HEAD~3 in this case. Now, that HEAD is on A and --mixed left your changes, you should be able to commit them all at once.

SevenEleven
  • 2,326
  • 2
  • 32
  • 32