5 ms·
The scenario is something I try very hard to avoid via workflow, but sometimes it still happens. Somebody merges something and pushes it to the master branch of
by justinhj 13y ago
The scenario is something I try very hard to avoid via workflow, but sometimes it still happens. Somebody merges something and pushes it to the master branch of the repo before it's ready. Now you want to pretend that never happened. You can't just revert it. If anyone can post instructions for easily getting the master branch back to how it was before the merge let me know.
- Osiris 13y agoYour problem is not undoing merges, but allowing people to merge that shouldn't. A good solution like GitHub Enterprise or Stash will allow you to use pull requests, so you can require that code gets reviewed by a third-party before merging. In the case of Atlassian Stash, you can set branch permissions, which allow only certain users to commit/merge to that branch, and you can also require that a merge request be reviewed by specific individuals before the system allows it to be merged. Preventing the merge problem in the first place is a much better approach than trying to fix it afterwards.
- thinkpad20 13y ago> Preventing the merge problem in the first place is a much better approach than trying to fix it afterwards. In a perfect world, all problems would be prevented. Unfortunately, we live in the real world, where being able to fix it afterwards is very important.
- justinhj 13y agoExactly. We use github enterprise. Our normal workflow prevents this problem, but shit happens.
- justinmk 13y ago> Somebody merges something and pushes it to the master branch of the repo before it's ready. Now you want to pretend that never happened. Say 'abc123' is the commit immediately before the merge commit. Run this: git rebase -i abc123 In the editor window that appears, delete the commit(s) that you want to "pretend never happened". Exit the editor. Git then replays the commits from abc123 up to HEAD, except without the commits you deleted. Now your local branch is in a state that omits the premature merge commit.
- steamer25 13y agoOr comparable to above, git reset --hard <previous commit's hash> and afterward you may have to git push --force ...to overwrite the changes in the blessed/central/public/shared repo.