What is it?
Git is a software that allows you to keep track of changes made to a project over time. Git works by recording the changes you make to a project, storing those changes, then allowing you to reference them as needed.
Local Version Control
Saves Files on a database on one computer.
Centralised Version Control
Saves Changes to a shared server.
Distributed Version Control
Allows for easier sharing of files and find local version control because you will be able to share them and it also eliminates problems that could occur if access to the server is lost under a centralised version.
Basic Git Workflow
- You modify files in your working tree.
- You stage the files, adding snapshots of them to your staging area.
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
Basics of Git
- Install Git from here for Windows, here for Linux and here for Mac
- During the installation, choose default settings for 'select components' screen, next use git from git bash only (recommended) and finally for line endings it is recommended that you stick with the first option and let git convert line endings for you.
- Once the install, we are gonna start off with local repositories and learn the basics before we jump into remote stuff. Open git bash.
- Type git init which will initialise a respiratory on a new folder or an existing one.
- After the command finishes go to where you saved git on when installing. Then go to view on the top left corner and tick the Hidden Items box. You should now be able to see a new hidden folder called .git which is where git stores everything including change sets, branches and so on.
- Where the .git file is, create a text file instead of a version control.
- Even though the text file exists, it isn't being tracked by git yet. To see this use the command git status on git bash.
- Git status is telling us our text file is untracked. To fix that we type git add (name of file).txt and press enter. git add=(adding files to the version control)
- When use git status again we see that our file is ready to commit. This process is called staging.
- Then type git commit for writing changes to the log.
- And finally type git push to send the changes to the central repository