In Git, when you click on the main branch, a commit occurs from the development branch. Is this supposed to happen? I am using gitflow

When I started working with git, I based my workflow on the Gitflow model: http://nvie.com/posts/a-successful-git-branching-model/ . I thought the main idea was to preserve the commit of the corresponding branches; so, for example, the main branch would only have commits that were merged from the development branch ... i.e. tags ... 0.1. 0.2. 1.0 in the chart. I don’t quite understand how git works or how this workflow is designed to work, but what I thought was all the more so since the graphical object on this page shows only these few commits on the main branch, and not all the developments.

I push my repo to Bitbucket, and everything went well while I was working in the development branch, however, when I finished the development; and by pushing up the master branch, I found that the main branch in Bitbucket now contains all the commits that I made in the development branch, while I thought that I would only contain the last commit (the one I combined). Can someone explain why this is, and whether this is the intended behavior, and if not what I can do to make my workflow work in accordance with the model above. I am using smartgit.

+4
source share
3 answers

It seems your branching model needs to specify --no-ff for each merge, forcing accounts even for empty merges - for example, on your chart, you do a merge with hotfixes up to 0.2, which gets this one commit on the master branch and actually not merge , with git merge --no-ff hotfixes . On projects with non-w20> -aware administrative requirements, this is a good way to do this. VonC answered for the case when you missed this model --no-ff .

In the case when you followed your model and simply did not expect that push will behave the way it is: if you check the master as of 1.0 in a repo with a graphical history and click on the remote main branch, when clicking terminates the console, there will be commit M2, M4, M5, Y1-6, G1-4, R1 and C1-3 (marking its fixation in accordance with their color and vertical sequence), and the remote main branch will apply to all of this.

What you need to understand is that commit histories are important, but link names are not, at least, are not important for capital-I. git push

Updates deleted links using local links when sending objects needed to complete specified links.

Usually, if your repo is part of the main project, you track some of the "central" repo names. Git default clone sets local remote / source / * branches for them; but other settings are not at all unusual; if you have a repo where you are working on v2.1 of a project, you can consider some other repo release-v2.1 branches as the "master" branch of your repo.

If you want to click only the results of a commit without clicking on your story, you must make a new commit that has results but does not have this story. Other dvcs were built by people who consider building stories in this way with varying degrees of disgust; Git sees options like none of his business: he provides (these) tools that implement any model you want to imagine. git cherry-pick will create a new commit by splitting the named commit into its first parent, and then applying this diff to the current voice, with a message telling the cherry has passed. Vanilla git rebase selects a whole sequence of such commits. The behavior I think you expected is that git merge --squash; git commit git merge --squash; git commit does: applies diff to the commit history and forgets where they came from. If you do this, no commit elsewhere will ever appear in the history of your branch. This is definitely not the model your graphics are trying to convey.

+3
source

It’s possible that when you merged the development branch with master you did a quick merge.
Unlike a git merge --no-ff , which ( man page ) "creates a command even when merging is allowed as fast forward."

This means that master HEAD just moves to dev HEAD, referring to all dev .

See " Why does git use default switching by default? "

+2
source

Please follow these steps. Maybe you yourself will know the answer.

  • Make sure that you are currently working on the correct branch

     git branch -a //Shows you all the branches git checkout {branch_name} //Make sure you checkout the correct branch 
  • Make sure you have the correct commits in your log

     git log --oneline -6 // Show last 6 commits on this branch 
  • If you see commits from another branch, then you could combine this branch in your current branch, otherwise you could make an error in this branch by mistake.
+1
source

All Articles