Difference between Source Branch and Target Branch
Source Branch:
This is the branch that contains the new work (such as new features, bug fixes, or updates).Target Branch:
This is the branch where the changes from the source branch will be merged into. Typically, this is themain
branch which is the stable or production-ready version of the project.
Main Branches
Main/Master Branch
: Themain
(ormaster
) branch is usually the default branch in a repository. It typically contains the production-ready code.Develop Branch
: In some workflows (like Git Flow), a develop branch is used as an integration branch where new features are merged before going into themain
ormaster
branch.
Pull Requests
A pull request is a request to merge changes from a source branch
(e.g., feature/new-feature) into a target branch
(e.g., main). The PR is reviewed before the merge.
Terms related to PRs
Merge Conflicts
: When changes in the source branch conflict with changes in the target branch, Git can’t merge them automatically, and human intervention is needed.Merge Commit
: The commit that results from merging the source branch into the target branch.Squash Merge
: A merge strategy that combines all commits from the source branch into one commit when merging into the target branch.
Merge Types
Fast-Forward Merge
: A merge that can be completed by simply moving the target branch pointer forward to the latest commit of the source branch (when the target branch has no new commits after branching off).Three-Way Merge
: When changes have been made on both branches, Git uses the common ancestor of both branches to perform a merge by creating a new commit that combines the changes from both branches.
Tracking Branches
A local branch tracks an upstream branch, meaning your local branch is aware of where it comes from and can fetch changes from or push changes to the upstream branch.
Remote Tracking Branches
: These branches track the remote version of your branches (likeorigin/main
ororigin/feature/new-feature
). They represent the state of the branches on the remote repository.Upstream Branch
: A term used to describe the remote branch that your local branch is tracking or linked to, such asorigin/main
for themain
branch.