Skip to content

Instantly share code, notes, and snippets.

@jcbwlkr
Last active February 9, 2016 21:49
Show Gist options
  • Save jcbwlkr/3fc4fed6d4c74b4b2be2 to your computer and use it in GitHub Desktop.
Save jcbwlkr/3fc4fed6d4c74b4b2be2 to your computer and use it in GitHub Desktop.

Git Workshop

What is Git?

  • Version Control System (VCS).
  • Much better than having
    • index.html
    • index.html_backup
    • index.html_before_bootstrap
    • index.html_working

Who cares?

  • Developers
  • Authors
  • Designers
  • Anyone that works with text

What can you do with it?

  • Keep a history of changes to files
  • Separate work on separate tasks
  • Merge work from separate tasks
  • Collaborate with others
  • Develop complicated workflows
  • Deploy code to production

Using the terminal

  • Open "Terminal" for Mac, "Git Bash" for Windows and probably "Gnome Terminal" or "Konsole" for Linux
  • pwd is your "present working directory"
  • ls lists files
  • cd is "change directory". Switch to the root directory of your project
    • Start typing a directory and hit Tab for easy navigation
    • Go up a directory with cd ..

Getting started

  • Install git. Available for Windows, Mac, Linux, others
  • git config --global user.name "Abraham Lincoln"
  • git config --global user.email honestabe@lincoln.com
  • git config --global color.ui auto
  • From project root run git init

Adding files

  • git status
  • git add
  • git status
  • git commit

Updating files

  • Edit a file
  • git status
  • git diff
  • git add
  • git status
  • git commit

Removing files

  • git rm file
  • git commit

Reviewing history

  • git log
  • git show
  • git blame

Branching

  • git branch
  • git checkout
  • git checkout -b
  • git merge
  • Branch master

Resolving conflicts

  • git status
  • git add
  • git rm
  • Merge markers <<<<<<<|=======|>>>>>>>

Remote Repositories

  • GitHub
  • Bitbucket
  • Others

Sharing your work

  • git remote add
  • git push

Contribute To Existing Projects

  • Fork on GitHub
  • Clone your repo git clone
  • Make a branch for your change git checkout -b myChange
  • Make changes and commit
  • Push changes git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment