This is a series of articles related to Source Control or Version Control issues, from a stand-alone app, such as MS SourceSafe, to a Server app, such as MS TFS (Team Foundation Server), to web services such as GitHub, AWS, and MS Azure DevOps. We have tried to categorize this series of articles as Source Control or Version Control, but this site does not have these categories. So, we put the articles in the DevOps category, as explained in the Wiki:
DevOps is a set of practices that combines software development (Dev) and IT operations (Ops). It aims to shorten the systems development life cycle and provide continuous delivery with high software quality.[1] DevOps is complementary with Agile software development; several DevOps aspects came from the Agile methodology.
The structure of this article series will cover:
- Stand Alone App:
- Server App
- MS TFS (Team Foundation Server)
- Online (Cloud) Centralized Service:
- MS Azure: DevOps
- Boards
- Repos
- Pipelines
- Test Plans
- Artifacts
- GitHub
- AWS GitHub Enterprise
- Distributed App:
Because these are huge topics, I will not go step by step. Instead, each section will be relatively independent and will become a reading unit.
- Source Control (1), MS Source Safe --- Stand Alone App
- Source Control (2), MS TFS --- Centralized Server App
- Source Control (3), MS Azure DevOps (GitHub, Jira) --- Centralized Service
- Source Control (4), Git --- Distributed App
- Source Control (4-1), Git --- Configuration
- Source Control (4-2), Git --- Configured to Connect to DevOps and GitHub
- Source Control (4-3), Git --- Cherry Pick in Visual Studio
- Source Control (4-4), Git --- Recover Git Tree: Reflog/Reset
- Source Control (4-5), Git --- Recover Deleted Branch
- Source Control (4-6), Git --- Revert
- Source Control (4.7), Git --- Get Specific Version or Commit
- Source Control (4.8), Git --- Get Specific Version or Commit in practice
- Source Control (4.9), Git --- Merge: Fetch, Pull, Push and Sync
- Source Control (5), GitHub access (setup connection)
- Source Control (6), DevOps access (setup connection)
- Source Control (7), GitLab access (setup connection and Clone to Local)
- Source Control (8), Git, Azure Repos, and Visual Studio (Interaction)
- Source Control (9), Push into Git Hub and DevOps
- Source Control (10), Git Hub, DevOps Publish
Introduction
We have discussed Merge for TFS in the article, Source Control (2-2), TFS --- Merge. We also discuss a little bit about Git Merge in the article, Source Control (4.9), Git --- Merge: Fetch, Pull, Push and Sync. Now I will discuss more about Git Merge,
- In Server Side:
- MS DevOps
- MS GitHub
- GitLab
- In Client Side:
- in Visual Studio
- by Git Prompt Command
I should emphases here, TFS Merge and Git Merge are quite different concept, while TFS is a server side centralized Software, client side interface, such as Visual Studio, is just a dummy interface, that is synchoronous with server, as a input/output interface at al, Git is a client side or distributed Software in client side, that is an independent software, it can be a indenpendent system working in client machine, the conversation to server, just push/pull the result to/from server to make client and server synchoronously.
In IDE, such as Visual Studio, you have to choose either using TFS or Git, choose:
Menu Bar => Tools => Options => Source Control => Plug-in Selections, got:
Git:
![]()
TFS:
![]()
Compared to TFS Merge, Git Merge has more choices, such as from Merge Strategies in Git - GeeksforGeeks, that
- Fast Forward
- Recursive
- Ours
- Octopus
- Resolve
- Subtree
But we will not discuss that kind of complex types, we will only discuss the basic types, say, most often happening in different Source Control Servers,
- Merge in Servers
- Merge in DevOps
- Merge (no fast forward)
- Squash Merge
- Rebase Merge
- Semi-Linear Merge
- Merge in GitHub
- Merge (no fast forward)
- Squash Merge
- Rebase Merge
- Merge in GitLab
- Merge (no fast forward)
- Squash Merge
- Merge in Client
- Merge in Visual Studio
- Merge (no fast forward)
- Squash Merge
- Rebase Merge
- Merge in Git --- all types of merges, but we only discuss
- Merge (no fast forward)
- Squash Merge
- Rebase Merge
- Semi-Linear Merge
We will discuss the contents in this article
- A - Introduction
- B - Merge in Visual Studio
- Merge (no fast forward)
- Rebase and Merge
- Squash Commits
- C - Merge by Git Command
- Merge (no fast forward) --- merge from feature branch to master branch
- Merge (Fast forward) --- merge from feature branch to master branch
- Rebase Merge --- Rebase feature branch onto master branch
- Squash Merge --- Squash two or more commits into one
B - Merge in Visual Studio
In Visual Studio Integrated Development Environment, we may have the following 3 ways to merges:
- Merge (no fast forward) --- merge from feature branch to master branch
- Rebase Merge --- Rebase feature branch onto master branch
- Squash Merge --- Squash two or more commits into one
Test Program:
For better understanding, I make this testing program in Visual Studio:
Master Branch:
![]()
Feature Branch
![]()
![]()
![]()
They all are starting from commit 577fd5aa at 0/10/2023 12:18:31, as
![]()
Merge (no fast forward):
Master check out:
![]()
Right Click the feature branch, test1, you want to merge it to the master branch => Merge 'Feature/test1' into 'master1':
![]()
The merged result is exactly as what we have in Source Control (4-10), Git --- Merge, the option Merge (no fast forward):
![]()
Rebase and Merge:
Feature Branch check out: --- due to we want to make a merge into the feature Branch and rebase it:
![]()
Right Click the master branch you want to use to rebase => => Rebase 'Feature/test3' onto 'master3':
![]()
The merged result is exactly as what we have in Source Control (4-10), Git --- Merge, the option Rebase and Fast Forward Merge:
![]()
Squash Commits:
Hilight the commits you want to merge:
Right Click => Squash Commits:
![]()
The three Commits merge
![]()
Click Squash, save A, save B and save C. three Branches are merged into one: save C. Click on new merged save C, see the right bottom, this Branch includes all three changes: A, B, and C:
![]()
The changes were used to be in save A, see t\right bottom:
![]()
in save B, see t\right bottom:
![]()
and in save C,respectively
![]()
C - Merge by Git Command
By Git, we can do all kinds of merges, but we only discuss the major ones:
- Merge (no fast forward) --- merge from feature branch to master branch
- Merge (Fast forward) --- merge from feature branch to master branch
- Rebase Merge --- Rebase feature branch onto master branch
- Squash Merge --- Squash two or more commits into one
Test Program:
We use the same test program as used above.
Merge (no fast forward implicitly):
Check status from command line: master1 is check out
git reflog
![]()
Check out master2:
git checkout msater2
![]()
Check the status from Visual Studio: master2 is checked out:
![]()
Merge test2 into master2:
git merge feature/test2
![]()
See the merged result from Visual Studio:
![]()
Merge (no fast forward explicitly):
We have
![]()
Check out master1
git checkout master1
![]()
Merge feature/test1 into master1 with No Fast Forward:
git merge --no-ff feature/test1
![]()
Result in Visual Studio:
![]()
Fast Forward Merge: --- not always work
Merge feature/test6 into master6 with Fast Forward:
git checkout master6
git merge --ff-only feature/test6
![]()
It does not work at all. Now, we knew the current commit history like this
![]()
master:
![]()
feature:
![]()
The Fast Forward merge is only working for the structure like this:
![]()
Get rid of the added commits, save 1 to save 5:
![]()
As expected, the Fast Forward merge is working:
![]()
Result in master6 in Visual Studio:
![]()
Squesh and Merge:
Master:
![]()
check out master4:
git checkout master4
![]()
Sqush Merge
git merge --squash feature/test4
![]()
the resutl is but not commit:, Seen from Visual Studio:
![]()
A message editor is open before you can commit the change:
![]()
Change to save or quit the editor, the commit make the merge done
![]()
See it from Visual Studio::
![]()
Rebase Merge:
Feature:
![]()
Master:
![]()
Rebase feature/test3 onto master3:
git checkout feature/test3
git rebase master3
![]()
Seen result from Visual Studio:
![]()
Semi-Linear Merge:
![]()
![]()
It is a mix of Rebase and Merge, the above description is for a process we push a commit to Server, say to DevOps, then the pushed feature branch will be rebased onto master and then merged into master. Let us demo this process from the client side:
- As demoed above in Rebase Merge: we have rebase feature/test3 onto master3
master3:
![]()
rebased test3:
![]()
- Merge test3 into master3:
git checkout master3
git merge feature/test3
![]()
Result in Visual Studio:
![]()
Reference
- Concept
- Server Side
- Clinet Client Side