How to handle a Git discontinuity?

Let’s say that in our Git repository, we worked on branch master for a while. Then, most of us started working on coolfeature branch, while a few developers continued on master.

Now, the developers who worked on master have lost interest, and what they developed since we forked isn’t very important. But we’d like the main development branch to be called master again. Conceptually, we’d basically like the tree to look something like this:

  • Getting ssh-agent to work with git run from windows command shell
  • Is there a way to “hide” merge commits in GitHub, when comparing branches?
  • git: put THEIR commits AFTER my commits with a single rebase command
  • Multiple file versions in git-lfs
  • SVN to Git Branch/Tag/Trunk
  • How do I handle images in a Git repo?
  • *--master--X      ----master
     \               /

    What’s the easiest way to achieve this? We really don’t want to try and merge coolfeature, and we’re happy for the commit marked X to be totally meaningless.

  • How do you manage to keep credentials out of publically browsable source code?
  • How can I get git and copSSH to look in the correct directory for keys?
  • git special characters on mac
  • Close Branch instead of merging?
  • Best practices for fixing a broken branch in Git?
  • Jenkins git plugin - show file change at Changes menu
  • 2 Solutions collect form web for “How to handle a Git discontinuity?”

    Perform a force push with the new master branch.

    git push -f origin master

    Other people fetch the code, and perform a reset

    git fetch origin master
    git reset --hard origin/master

    The way I would do this and avoid doing a forced push:

    1. create a tag for the commit X that you don’t care about. (You’ll see why in a minute.
    2. Perform a git revert of all the commits on the master branch since you branched off coolfeature. This puts the repository back to the state it was at the time you forked, but it doesn’t rewrite history, so nobody’s repository gets broken if they didn’t get the memo.
    3. Merge coolfeature onto master.

    The point about tagging X is to mark the point before you did all the changes. Tags are cheap, and at some point you might want to know the point at which you backed out commits and made such a change.

    Git Baby is a git and github fan, let's start git clone.