Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  • Merge
  • Conflits
  1. Basic Concepts

Branches

A branch is a series of commits. Any commit resides in one (or more) branch.

  • Every branch has a name. The default branch is called master in Git.

  • A new branch can stem from an existing branch. This is typically used to test new ideas (e.g. to try another network architecture), while the working code remains undistrupted in the original branch. This is why a branch is like a parallel universe.

  • Branches can be merged. Once the new idea is fully working, you can incorporate the changes back to the original branch.

Merge

There are two types of merges.

It's quite staightforward if one branch is simple ahead of another branch. This is called a fast-forward merge. Otherwise, it's a non-fast-foward merge. In this case, Git will try to combine the two versions together.

Conflits

During a non-fast-forward merge, conflicts may occur. E.g. one branch changes the batch size to 32, while the other changes it to 64. Which one should the merge use?

In this case, Git will let you determine the result. This will be done by asking you to select the change to keep.

PreviousCommitsNextRemotes

Last updated 1 year ago