开发者

Prevent unwanted commit from re-entering git history when doing pulls

开发者 https://www.devze.com 2023-03-22 00:58 出处:网络
I work in a distributed team and use a central git repository to collaborate on certain tasks (not code).We have several team members who are light git users, comfortable with push, pull, add commit,

I work in a distributed team and use a central git repository to collaborate on certain tasks (not code). We have several team members who are light git users, comfortable with push, pull, add commit, status, etc; but not the more advanced concepts.

Recently a very large commit开发者_Go百科 was added accidentally which we wanted to remove. I did a rebase -i, removed the errant commit (which had over 1gb of binary files), and push -f'd the changes back.

However, every time a member did a git pull in the future, it merely merges their local changes back into my changes! How do I force them to discard their local commit history and use mine. My solution was to email them all and do:

git fetch
git checkout origin/master
git branch -f master origin/master
git checkout master

Is there any better way?


You could add an update hook that verifies the offending commit is not in the history that they are attempting to push, and rejects the push if it does contain the commit in question.


git revert commit_hash

This should revert the changes that that commit introduced and create a new commit with those changes removed.This is preferable as it shows the history of the changes being introduced, then the changes being removed, instead of trying to pretend like it never happened.

0

精彩评论

暂无评论...
验证码 换一张
取 消