Source code control basics
# git
GitHub
remote repo: "origin"
You
local repo
workspace
Your team mate
local repo
workspace
local repo
workspace
Your team mate
# git
stash
workspace
local repo
index
remote repo
Under the carpet: hide things from git
Files you are working on
Changes staged for commit
Hidden folder keeping track of commits
Online backup for sharing
# git
stash
workspace
local repo
index
remote repo
# git
workspace
local repo
index
remote repo
<my changes to some files>
# git
workspace
local repo
index
remote repo
<my changes to some files>
git add Project.cs
# git
workspace
local repo
index
remote repo
<my changes to some files>
# git
workspace
local repo
index
remote repo
<my changes to some files>
# git
workspace
local repo
index
remote repo
<my changes to some files>
git commit -m "Change the project file in this specific way"
# git
workspace
local repo
index
remote repo
<my changes to some files>
# git
workspace
local repo
index
remote repo
<my changes to some files>
git push origin main
# git
workspace
local repo
index
remote repo
<my changes to some files>
# git
workspace
local repo
index
remote repo
<someone else's changes>
<my changes>
# git
workspace
local repo
index
remote repo
<someone else's changes>
<my changes>
git pull
# git
workspace
local repo
index
remote repo
<someone else's changes>
<my changes>
# git
workspace
local repo
index
remote repo
<someone else's changes>
<my changes>
Merge remote-tracking branch 'origin/main'
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# .git/MERGE_HEAD
# and try again.
# On branch main.
# Your branch and 'origin/main' have diverged,
# and have 1 and 1 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
~
~
~
~
# git
workspace
Merge remote-tracking branch 'origin/main'
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# .git/MERGE_HEAD
# and try again.
# On branch main.
# Your branch and 'origin/main' have diverged,
# and have 1 and 1 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
~
~
~
~
:wq
# git
# git