Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 3
    What are the repercussions of doing this if other branches regularly pull from the repo (fast forwarding only)?
    – Gabe
    Commented Nov 21, 2011 at 15:23
  • 1
    @whoami: If someone else pulls that branch, they will see (forced update) and git will refuse to update their branch. They then need to (a) make sure that all their work is committed (b) typically either rebase (e.g. with git rebase origin/master) or reset their branch to the remote-tracking branch version that's just been force-updated (e.g. with git reset --hard origin/master). Unless you're happy explaining to people what to do, it's definitely best not to force-push rewritten history. Commented Nov 21, 2011 at 15:30
  • They will all see that their local branches and the remote have diverged and will have to merge the changes in rather than just fast forward. Commented Nov 21, 2011 at 15:30
  • @Noufal Ibrahim: The problem with merging in that situation is that they will still have all the small commits in their merged master branch, and might push them back to the repository. Commented Nov 21, 2011 at 15:33
  • 1
    @whoami: Yes, it's best to restrict history rewriting to commits that you haven't pushed yet. If you know exactly that you want to squash all the last N commits, reset --soft and committing is probably easier, but if you want to selectively squash and reorder commits, using git rebase -i will give you that flexibility. (Also it depends which commands you're more familiar with...) Commented Nov 21, 2011 at 15:45