A
A
Anton Guz2014-11-14 13:49:30
git
Anton Guz, 2014-11-14 13:49:30

How to work with git history in a team?

There are teams. There is a command github. There is a ready pull request in the mainline. But some commits do not match the command agreement.
That is, deep in history there are several commits that:

  • you need to fix the author of the commit
  • you need to fix the commit message

How to do this without breaking the work of other teams, your team?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DancingOnWater, 2014-11-14
@DancingOnWater

Moment number 1.
The hashcode of the commit is calculated taking into account the text of the commit and the details of the author and the hashcode of the previous one. Hence the conclusion that they cannot be changed without changing the entire commit tree of the pull request.
There is only one way out - to rebase your branch with all the consequences and resubmit.

P
Power, 2014-11-15
@Power

If you merged from mainline to your branch and all of them passed without conflicts, then your task will be solved
(just don't reorder commits - see BUGS ).
If there were conflicts, and indeed it is more correct to do git filter-branch, for example:

git filter-branch --env-filter 'export GIT_AUTHOR_NAME="New Author Name"' --msg-filter 'if [ "$GIT_COMMIT" = "339167af5c274dedd5efcf93f83f4bfc4acb9eba" ]; then echo "new commit message"; else cat; fi' -- mainline_branch_name..your_branch_name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question