Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Version Control with Git

Introduction to Version Control with Git

These are the slides used in my Skillshare workshop on Introduction to Version Control

Avatar for Will Soares

Will Soares

March 28, 2018
Tweet

More Decks by Will Soares

Other Decks in Programming

Transcript

  1. Front-end Developer Bachelor of Computer Science Write posts at dev.to

    and my blog willamesoares.com willamesoares @willame_soares
  2. Course Overview ❏ Who is this course for? ❏ What

    is the goal of the course? ❏ How progress will be measured?
  3. History of Version Control Tools ❏ Problem: tracking files efficiently

    ❏ Limitations: concurrent work ❏ Centralized vs Distributed
  4. History of Version Control Tools Centralized ❏ central server ❏

    subtrees ❏ can be slow Distributed ❏ local copy ❏ work offline ❏ fast
  5. What and How ❏ Distributed version control system ❏ Most

    operations are local ❏ Uses snapshots ❏ Creates SHA-1 hashes based on file content 31c4e1d01bac28de52aed1a2d83f422a3dbea8d5
  6. Install git Mac $ git --version … or you can

    go to http://git-scm.com/download/mac
  7. git config ❏ System wide configuration: --system ❏ User specific

    configuration: --global ❏ Project specific configuration: --local
  8. git config $ git config --global user.name “John Doe” $

    git config --global user.email “[email protected]” Username and email
  9. git config $ git config --list Check configuration $ git

    config user.email $ git config --global --list $ git config --system --list
  10. git config $ git config --global alias.cfg config Create aliases

    $ git config --global color.ui true Colored user interface $ git config credential.helper store Save credentials
  11. Creating git repositories $ mkdir hello-world && cd hello-world Create

    your own $ git init Now you have your .git directory! $ git init hello-world or
  12. Committing your changes $ git commit -m “Add file to

    start listing greetings” $ git show
  13. $ echo “Hello” > README.md $ git add README.md $

    git commit “Update README.md to say Hello” Conflicts may happen! You update README.md and commit your changes
  14. $ git checkout master $ echo “Ola” > README.md $

    git add README.md $ git commit “Update README.md to say Ola” Conflicts may happen! Then you move back to master branch and update README.md as well
  15. $ git merge feature1 Conflicts may happen! Then you try

    to merge your feature1 branch into master branch
  16. Conflicts may happen! Steps 1. Open the file with conflicts

    in your editor of preference 2. Update it as you want and save it 3. Now, the file will be in your working directory, but this time if you check its contents... $ git diff
  17. Conflicts may happen! Steps 5. Move file to the staging

    area 6. Continue with merge process $ git add README.md $ git merge --continue
  18. Project 1. Fork the repo located here https://github.com/willamesoares/git-intro 2. Clone

    the forked repo to your local machine 3. Edit the CONTRIBUTORS.md file by adding your full name to it 4. Create a commit and send it to your master branch 5. Use the github interface to open a pull request $ git remote add upstream https://github.com/willamesoares/git-intro.git