Question about git. I worked on dev branch and made 10 commits.

Then I squash merged 10 commits from develop to master and made a release build.

Now problem is if I make a pull request from develop to master bitbucket will still show that master is behind (because develop has fixes in 10 commits while master has all of them squashed in 1 commit).

Now my question is whats the best way to make sure master and develop are synced (basically that master would have everything what develop has) ?

should I just merge master into develop back after the release?

  • 4
    Sounds like your develop branch has the 10 commits still? You should squash them on your develop branch first and then merge your branch into master so both will be at the same commit
  • 0
    @beegC0de yes that is much smarter :/ but if I do that, hashes of commits will not match with master, even if count is same
  • 1
    @zemaitis if you do 10 commits on top of master in your develop branch, squash them into one commit on your develop branch, then merge into master, it will just be a fast forward which the two branches will then have all same commits
  • 0
    Agreed with above. Reading the post the first mistake was “squashing develop into master” ;)

    Raises alarm bells because ultimately you are pushing changes to master which should be a big no no.
  • 0
    @Santaclauze sorry, but what did you mean by pushing to master is a no no?
  • 0
  • 0
    I prefare to rebase my dev branch (git checkout devbranch && git rebase master) and then merge it to master (git checkout master && git merge devbranch). It's most of the time more clean I think but conflicts can be nasty. Best is to rebase often while developing to always be as close to the master as possible
  • 0
    @ShotgunSurgeon oh and for squashing I rebase onto master first then squash on the devbranch and then merge into master
  • 0
    Why do you need to create a pr from development branch after squash merging them in master?

    Are you doing git flow?

    I always consider my feature braches closed after merge. They have done their duty. I would work on a feature brach, squash its commit to one, and then merge the feature branch to develop. The feature would then go to the master by merging develop into master. (Details change if you have release branches as well.) All merges should be fast forwards.
Add Comment