Skip to content

Instantly share code, notes, and snippets.

@zgulde
Created July 26, 2016 15:53
Show Gist options
  • Select an option

  • Save zgulde/50a100e60a7dad73c8de526634a3e468 to your computer and use it in GitHub Desktop.

Select an option

Save zgulde/50a100e60a7dad73c8de526634a3e468 to your computer and use it in GitHub Desktop.

Using Git

A common way to manage the versions of your files and content is to name files with increasing levels of description. Example: Resume.pdf, Resume_Final.pdf, Resume_Final_Monday.pdf, Resume_FINAL_to_print.pdf, and Resume_print_before_interview.pdf vs. a permanent record with a time machine that can enter paralell dimensions

Git, the Big Picture

  • Git is a permanent record.
  • Git is a time machine that allows us to travel through that permanent record.
  • Git also allows us to travel into parallel universes (branches)
  • GitHub is a service that hosts remote repositories.

Git allows us to version our files and their contents by allowing us to take snapshots called commits. Our filenames remain the same and the history of commits creates a permanent record for our code and contents that have been in that file.

Git Workflow

"Commit early, commit often" and "If code is not in GitHub then it doesn't exist"

  • cd into your local git repo (~/vagrant-lamp/codeup.dev/)
  • type git status between each step to orient yourself.
  • Add or modify your files inside your local git repo.
  • Add individual files
    • git add hello_world.html or git add README.md
    • git add public/css/style.css
  • git add -A to add all files (not recommended, but useful)
  • git commit in order to create a new commit of your added files.
  • Write a useful git message that explains what you're doing and why.
  • git push origin master
git
permanent record
time machine
repositories
local - on your own machine
remote - on github.com
starting a repo
create a new remote repo at http://github.com/new
create a new local repo in the local folder
- cd ~/vagrant-lamp/sites/codeup.dev/
- git init
- git add filename.html css/site.css
- git add .
- git add -A "adds all the things"
- git commit
- git status at any time
- git remote add origin <remote repo addy>
- git push -u origin master
working in an existing repo
- add and modify your files
- type `git status`
- `git add filename.html` or git add -A
- git commit
- git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment