Domanda

I have a single branch git repository, that has ~4000 commits. I want to group the commits according to dates they were created. For example, given the commits below:

abcd 2013-4-1 12:10
abce 2013-4-1 13:27
...
cdef 2013-4-1 18:16
cdeg 2013-4-2 09:23
...
gade 2013-4-2 18:20
fdeg 2013-4-3 09:42
... 

I would like to get a commit history such as all abcd-cdef commits merged into one commit, all cdeg-gade into one and so on. I tried to use rebase as

git reset --hard cdef
git rebase -i abcd

I couldn't manage to squash all the commits, got the folloving error message.

"Cannot 'squash' without a previous commit"

I tried to squash one commit at a time, it worked, but it took so long that it is clearly not feasable.

How can I merge the commits according to their creation dates?

È stato utile?

Soluzione

Mark the first commit from each day as "reword" and the rest as "fixup":

reword xxxxxx First commit from 2013-04-01
squash xxxxxx another commit from 2013-04-01
squash xxxxxx another commit from 2013-04-01
reword xxxxxx First commit from 2013-04-02
etc

This will prompt you to write a new commit message for each day.

Note that doing commits on a time basis is almost always the wrong thing to do. For tools like git bisect to work correctly, each commit in a repository should represent a "bite-sized" change.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top