Git Version Control for the Complete N00b by Adam LaBarge
1.
2. What is Git? What is version control?
Version Control: Version control is a system that records changes to a file/s over time
so that you can recall specific versions later.
GIT: Git is version control software developed by Linus Torvalds aimed at being faster,
distributed and focused on data.
- snapshots of data over time (states)
- nearly every operation is local
- integrity with checksums
- git generally only adds data
3. Git files states. “Now pay attention”
The 3 states of a file.
COMMITTED: Data has been safely stored into the local database.
MODIFIED: File/s have changed, but they are not yet safely stored. (committed)
STAGED: File/s have been marked for commit.
4. WHY USE IT?
- Easier than making your own version control system in your file system with new
folders and different copies of this and that.
- Better history and operations structure.
- Remote repositories allow for data integrity and backup of files.
- Working in a team in a manageable way.
- True me, the day will come when you are very thankful you are using it.
5. HOW TO INSTALL
Git is a command line application. There is no GUI app by default.
Mac: download the install app and proceed
Windows: download ‘git for windows’ app and proceed
Linux: command line install
6. PICK A GUI APP (HTTPS://GIT-SCM.COM/DOWNLOADS/GUIS)
7. DO I NEED GIT REPOSITORY HOSTING SERVICE
Technically, no. But yes, you really do!
What is it?
- a place to externally house your file/s changes
- manage access to code base
- wikis and other services (error checking, QA testing, etc)
Options:
- GitHub. - GitLab Account Types:
- BitBucket - Heroku Free vs. Private
8. GIT COMMANDS
Commit – saving code changes to the database
Push – pushing committed code to a repository
Pull – pulling committed code from a repository & merging
Fetch – pulling committed code from a repository
Branch/Fork – splitting the code base into a new version
Merge – combining two versions of code
Revert – going back to a previous history stage
Checkout/Reset – setting a file/s back to the committed state in the repo
Conflict – when Git does not know how to auto merge code
9. USING GIT
Create a .gitignore file (file/s we don’t want in the repository)
Create a Git instance
- Export the /.git directory
- config
Add remote repository
Add files to commit
Commit files
Push to remote repository
Now lets make changes, forks, commits
11. USING GIT IN DEPLOYMENT
SSH – command line git on your stage and production servers (preferred method)
Hosting companies own versions.
- WP-Engine
- ssh keys, pushing from command line, error testing code
- Pantheon
- similar but everything is controlled via their GUI
Positives & Negatives:
- in some ways it is easier – docs have been written, someone else thinking for you
- when changes are made directly to server, is a PITA to get it into the repository
12. WAYS TO MAKE GIT EASY
- Always try to move forward
- Try never to revert (the revert work around with GitHub downloads)
- Don’t be scared to make mistakes
- If in doubt, copy everything out, start again
- Learn your host repository interface, they are there to help
- Write logical commit messages
- $ git status
- $ git checkout –b {branch}
- $ git pull origin {branch}
13. OH SNAP! NOW WHAT
Google and tutorials
- stackoverflow.com has many great answers
- http://rogerdudler.github.io/git-guide/
- https://git-scm.com/about