News for hackers. Stuff that matters.
Re:Why is git pull considered harmful? (2013) by jarrett on Wednesday March 12, 2014 @11:55AM (#7386354)
My policy is this: You may rewrite commits you've made to your local repo since your last push, but you may never rewrite a commit that has been pushed.

Your teammates don't care much if you do the former. From their perspective, it's the same as if you'd committed at different points in your development process. So long as your final, rewritten history doesn't violate your team's preferences as to the granularity of commits, you're fine.

So go ahead and rewrite your local, un-pushed changes if you feel it makes the history more organized.

But if you do the latter--rewriting history that has been pushed--you're in trouble. All developers should be able to assume that the history in the central repo is immutable. Most likely, they will rely on that assumption.

Re:Why is git pull considered harmful? (2013) by icambron on Wednesday March 12, 2014 @12:02PM (#7386402)
I'd like to separate private from local. I allow for private branches on the central repo to be mutable. (By "private", I just mean marked in such a way that its clear it's owned by a particular user.) Otherwise, people end up keeping their changes local until they're ready to merge and you lose the backup aspect of git. But no one should be merging private branches (regardless of location) without their author giving an explicit OK anyway, so this doesn't seem dangerous.
Re:Why is git pull considered harmful? (2013) by jarrett on Wednesday March 12, 2014 @12:10PM (#7386458)
That's a good point. How do you synchronize history rewriting across the local and remote copies of the private branches? Do you have a formalized way to ensure it doesn't get messed up?
Re:Why is git pull considered harmful? (2013) by benesch on Wednesday March 12, 2014 @01:46PM (#7387083)
If you enforce a convention that private branches start with the developers initials (nb-restructre-everything), and that developers can force-push only their own branches, you can rely on each developer to keep their remote up-to-date.

You can even rewrite a branch shared between developers that hasn't been merged mainline: once it's done, have one of the developers create a duplicate branch in their own private namespace, and rebase and merge that.

Accidents happen, though. If you want to be guaranteed safety, enforce that every developer have their own remote fork. They can rebase at-will on their own fork, and submit pull requests to the mainline repository. (If you're using GitHub, this is dead simple, since you can open pull requests across forks.) This method introduces a fair bit of hassle and overhead for a smallish team, though.

Re:Why is git pull considered harmful? (2013) by acchow on Wednesday March 12, 2014 @01:38PM (#7387040)
Where I work, you prefix the name of your branch with your username, like "acchow/new-feature". This tells other people "do not touch this branch because its history will be changed by acchow".

Alternatively, if you use github, you can set access controls on forks to read-only and send pull requests from your fork to the main repo.

Re:Why is git pull considered harmful? (2013) by icambron on Wednesday March 12, 2014 @01:58PM (#7387155)
What benesch said, basically: just force push your own branches. Have to be careful if you work from multiple computers, though.
Re:Why is git pull considered harmful? (2013) by ngoldbaum on Wednesday March 12, 2014 @12:12PM (#7386477)
Incidentally this is the enforced-by-design behavior of mercurial with respect to history modifying actions.
Re:Why is git pull considered harmful? (2013) by jheriko on Thursday March 13, 2014 @07:52AM (#7391192)
> All developers should be able to assume that the history in the central repo is immutable. Most likely, they will rely on that assumption.

Amen.