Search code examples
gitmergebitbucketgit-merge

Is it possible to remove commis present in one branch, which are absent in another branch?


I am using Git (Bitbucket) have one master branch and two release branches like below;

master
  '--release/1.0
       '--release/2.0

In an ideal situation, all commits in release/1.0 will be present in release/2.0 and master. Also, all commits in release/2.0 is present in master.

Due to some reasons, here are some extra commits present in master, making it ahead of release/2.0. I want to sync release/2.0 with master, that extra commits present in master which are not present in release/2.0 should be removed. Is this possible?


Solution

  • Assuming you mean you just added commits in master (as opposed to having them interlaced somewhere done the tree), you could just reset the master branch:

    # switch to master
    $ git checkout master
    
    # reset it to release/2.0
    $ git reset --hard release/2.0