Reputation: 28372
I would like to have the capability to verify that the user has rebased changes from a tracking branch into the feature branch so that the feature branch changes appear after any tracking branch changes.
Furthermore, I would like to make sure that all the new changes in the feature branch have linear history.
Is there a way to accomplish this?
Upvotes: 2
Views: 128
Reputation: 28372
I found this related question, from which I think a solution could be pieced together:
START=`git rev-parse origin/master`
git rev-list --count --min-parents=2 --ancestry-path ${START}..HEAD
Will print out the number of commits between ${START} and HEAD with more than one parent. There are more details to work out such as ensuring that latest commit in origin has previously been rebased into the local branch.
Upvotes: 0
Reputation: 1323503
You can, as in this answer, setup a pre-receive hook on the server side (where you are pushing to) in order to check if there is any merge commit (commit with more than one parent)
That would ensure rebase and linear history.
But that must be done on the server side (it cannot be easily checked on each client)
And, again if you have access to the server side, set as seen here the configuration git config --system receive.denyNonFastForwards true
.
Upvotes: 1