Git+&+Github +branching
Git+&+Github +branching
Bug Fix
New Color Scheme
Bug Fix
Experimental redesign
New Color Scheme
Bug Fix
Experimental redesign
New Color Scheme
Merge!
Bug Fix
Experimental redesign
You Probably Have
Seen This Before
On branch master
nothing to commit
The Master
Branch
In git, we are always working on a branch* The
default branch name is master.
92faa...
Experimental Branch
Branching
Master Branch
987fac... 236ff...
92faa... 232fa...
Experimental Branch
Branching
Master Branch
236ff... 566ff...
987fac...
92faa... 232fa...
Experimental Branch
A Common Workflow
Master Branch
Merging back
to master
Master Branch
Fitz's Branch
commit bca5fc8b05deda4a13e7588c7ca352e47560c1dd
(HEAD -> master)
WTF IS THAT
CRAZINESS
HEAD? What Is That?
HEAD
We'll often come across the term HEAD in Git.
Master Branch
HEAD
Fitz's Branch
HEAD
Ethel's Branch
Master Branch
Fitz's Branch
Ethel's Branch
Master Branch
Fitz's Branch
HEAD
My First Commit
On Master
Master HEAD
987fac...
Another Commit
Master HEAD
987fac... 236ff...
I make a new branch!
Master
987fac... 236ff...
DarkMode
HEAD
I make a commit on
the new branch
Master
HEAD
987fac... 236ff...
DarkMode
92faa...
2nd Commit
On New Branch
Master
HEAD
987fac... 236ff...
DarkMode
92faa... 232fa...
Return to Master
Master HEAD
987fac... 236ff...
DarkMode
92faa... 232fa...
Going Back To My
Dark Mode Branch
Master
HEAD
987fac... 236ff...
DarkMode
92faa... 232fa...
Merge Changes
Into Master Branch?
HEAD
92faa... 232fa...
DarkMode
Viewing
Branches
Use git branch to view your existing branches.
The default branch in every git repo is master,
though you can configure this.
❯ git branch
987fac... 236ff...
❯ git branch bugfix
Master HEAD
I've made a new branch,
but I'm still working on master.
987fac... 236ff...
Bugfix
Switching
Branches
❯ git switch <branch-name>
Once you have created a new branch,
use git switch <branch-name> to switch to it.
❯ git switch bugfix
I've now switched over to the
Master new bugfix branch!
987fac... 236ff...
Notice that HEAD is now
pointing to Bugfix, not master.
Bugfix
HEAD
When I make a new commit, it
exists only on my new branch,
not on master!
Master
HEAD
Bugfix
987fac... 236ff...
92faa...
And another commit...
Master
HEAD
987fac... 236ff...
Bugfix
92faa...
❯ git switch bugfix
92faa... HEAD
bugfix branch
Another way of
switching??
Historically, we used git checkout <branch-name>
to switch branches. This still works.
92faa... HEAD
refactor branch
master branch Remember, branches are
987fac... 236ff...
made based on the HEAD
bugfix branch
If I branch from the bugfix branch,
master branch my new branch includes all the
987fac... 236ff...
commits from bugfix.
bugfix branch
92faa...
new branch!
Viewing
❯ git
More Info
branch -v
Use the -v flag with git branch to view more * master 88df51f add documentation
information about each branch. bugfix 7c2a586 fix hover bug
chatdemo afadcf9 add chat widget