Git merge branche Development into master

Today the standard source control with Visual Studio is GIT. This source control has a lot of powerful features and options.

For me it took some investigation, testing and searching the internet on how to best merge a development branch (or a bugfix branch, etc.) into the main (master) branch.

git checkout master
git merge –squash Development
git commit OR git commit -m “This is a merge from branch to branch at moment x”

What these commands will do is compact all commits to the development branch and add them to the master in one separate commit.

ATTENTION: When you check the source tree you will also notice that there is NO “merge branch” line.

Next I have added an extra branch, commit a change. Last action was to merge the branch using “git merge HotfixOnMaster”:

After merging a complete branch without squashing. Every commit remains in the master history:

Alternative found on makandracards.com:
Squash several Git commits into a single commit
This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as one pretty commit.

git checkout master # Switch to the master branch and make sure you are up to date.
 git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
 git pull
 git merge feature_branch # Merge the feature branch into the master branch.
 git reset origin/master # Reset the master branch to origin's state. Git now considers all changes as unstaged changes. We can add these changes as one commit. Adding, will also add untracked files.
 git add --all
 git commit

Note that this is not touching the feature branch at all. If you would merge the feature branch into the master again at a later stage all of its commits would reappear in the log.
https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit