git - Can rewriting history of a single-developer branch be dangerous? -
i use branches backup of wip. coming want have git diff back, can have again overview on changes while continuing work.
so reset wip-commit (git reset head^) , start work again. when need commit again (a definitive commit or wip-commit) , push remote origin i wonder if new diverging commit create problems collaborators pulling same branch.
i know if make changes , commit. if pull branch never touch it, , consequentially pull second new diverging wip-commit?
is safe enough agree not touch branches of collaborators?
if last commit has not been pushed, git reset head^ not mess up. if have pushed, recommend against it, if other collaborators not modifying branch. let's make initial commit a , push it, git reset head^ , make commit b. when try push it, error because b has same parent a, , git cannot fast forward merge on server. error message recommend git pull in case. once do, have new merge commit merges a , b.
now, around doing force push (thus blowing away a), work if nobody has pulled repo since pushed a. otherwise, next time pull merge a , b on local machine, , push merge server.
so long story short: never rewrite history has been pushed.
Comments
Post a Comment