What is Source Control?
- A control/system/tool used to control your (source) code
- Also known as revision control
What is Source Control?
Why use GIT?
What is GIT?
How to use GIT?
git clone
: Downloads a project and its entire version historygit status
: List any changes you've made since the last save pointgit branch
: List all local branchesgit checkout
: Switch to another branch (all your files will automagically change to the last saved version of that branchgit add
: Prepare (aka stage) files to prepare for saving (aka committing)git commit
: Save the staged filesgit merge
: Combine to two saved (aka committed) versions and automagically make sure each change is accounted forgit push
: Upload the saved changes to the remote repository (e.g. Github)git pull
: Download the saved changes from the remote repository (e.g. Github) since the last git pull
Note: Be sure to check on what state your code is in by issuing git status
and/or git branch
at any time when performing the following steps
git checkout -b feature/my_branch
-b
means create feature/my_branch
alsofeature
is just a naming convention; there's nothing special to itgit checkout
command, issuing a git status
should show that you are on the feature/my_branch branch
git add .
git add
will stage your updates in preparation to be committed.
means to stage all of your updates in preparation for committinggit commit -m "my commit message"
git commit
will save the updates you've staged-m
says use my commit message
as the commit messagegit checkout master
master
branchmaster
is the name of the primary branch that is typically used by many GIT repositoriesgit pull origin
git merge feature/my_branch --no-ff
feature/my_branch
with the code in the master
branchgit push origin
origin
is the name of the remote repository that is typically used by many GIT repositoriesorigin
something else and even add more remote repositoriesgit add
, git commit
)git commit
, git branch
, git checkout
, git merge
)git pull
, git push
)git diff
allows you to see the exact changes
git diff file1 file2
to see the differences between two filesgit rebase
allows you to move a branchgit log
allows you to see the commit history
git log --graph --oneline --decorate --all
git stash
allows you to temporarily save your changes so you can switch branches or start over from the last saved commit
git pop
will bring those temporarily saved changes backgit stash
and git pop
; you really have to know which stash is going to be brought back and how.git
folder.git/config
filegit status
command before each GIT command to make sure the state of the files are in the state you think they are