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

Git started - Introduction to distributed version control

Git started - Introduction to distributed version control

Yannick Baron

October 24, 2017
Tweet

More Decks by Yannick Baron

Other Decks in Programming

Transcript

  1. Architect at Thinktecture Not a Delphi Developer Not a git

    guru Using git for 11 years now Migrated many projects from SVN First step in new project: git init Who am I?
  2. Why version control? Distributed? Live Demo: Writing a “book” with

    git Web platforms and their features Social coding: Git a free T-Shirt Git UIs Outline / Motivation
  3. Time travel: Go back in time History of how project

    evolved Compare versions to find errors Build releases on versions Work on the same files in parallel Why version control?
  4. Changes are kept track of locally Most operations performed locally

    Server mostly for storage only Control of when to communicate with a remote machine = fast + independent of connection Distributed?
  5. git init initializes a git repository git status information about

    the current state git add <filename> adds current version of a file git commit –m “<msg>” saves added files to the history Gitting started is easy
  6. The git history is a graph, a tree to be

    precise A node in that tree is the state of our files at a point in time Most operations deal with how to navigate and manipulate that tree The git history
  7. git add --all adds all untracked files at once git

    status information about the current state git commit –m “<msg>” saves added files to the history Growing the tree
  8. git branch <name> creates a new branch at HEAD git

    checkout <branch> moves HEAD to branch git commit –am “<msg>” -a add all tracked files & commits Adding a branch
  9. git checkout <branch> moves HEAD to branch git diff show

    the diff of current changes git commit –am “<msg>” -a add all tracked files & commits Switching branches
  10. git diff <branch> diff between HEAD and given branch git

    checkout <branch> moves HEAD to branch git merge <branch> –m “<msg>” merges branch into current branch git branch –d <branch> deletes given branch Reintegrating a branch
  11. git init git status git add git commit git branch

    git checkout git diff git merge Recap #1
  12. git log shows full detail log of all commits git

    log --oneline shows list of commit messages git log --graph --oneline shows graph of commit messages The Log and Hashes
  13. git checkout <SHA> -- <file> checks out file in given

    version git diff --staged shows a diff of the staged files git reset --hard <SHA> move current branch back to SHA --hard discard all changes --soft keep changes We have to go back!
  14. git remote add <name> <url> adds a remote repository git

    push -u <remote> <branch> push branch and setup tracking git push push changes of current branch git checkout –b <branch> -b create and switch to branch Going online for the first time
  15. Starting from existing Repo git clone <url> [<folder>] makes working

    copy of repo at url git log --graph --oneline shows graph of commit messages Multiplayer
  16. git checkout <branch> moves HEAD to branch git commit –am

    “<msg>” -a add all tracked files & commits git push push changes of current branch Player 2 has entered the game
  17. git fetch download changes from the remote git checkout <branch>

    moves HEAD to branch git pull merges changes into current branch Receiving changes
  18. git merge <branch> –m “<msg>” merges branch into current branch

    git commit –am “<msg>” -a add all tracked files & commits git push <remote> :<branch> deletes branch on remote git branch –d <branch> deletes given branch Dealing with conflicts
  19. We have seen 15 basic commands That’s all you need

    to git started Just the tip of the iceberg Git is a skill, a tool in your tool belt Expertise makes your life easier Low cost, high reward Try it! Git going!
  20. and their features GitHub https://github.com BitBucket https://bitbucket.org GitLab https://gitlab.com Create

    online repositories Fork Repositories Pull Requests Tools for Code Reviews Continuous Integration Build Pipelines Web platforms
  21. Git a free T-Shirt #hacktoberfest 1 more week to go

    https://hacktoberfest.digitalocean.com/ Make an Account on GitHub Fork a repo Make a branch and contribute Make 4 Pull Requests Git your T-Shirt! Social coding:
  22. SourceTree (WIN, OSX) Free with all features https://www.sourcetreeapp.com GitKraken (WIN,

    OSX, LINUX) Free for non-commercial, limited https://gitkraken.com Tower (WIN, OSX) 30 day trial with all features https://www.git-tower.com Git UIs