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

'Git started' - verteilte Versionsverwaltung mit Git

'Git started' - verteilte Versionsverwaltung mit Git

Motivation: Warum Versionsverwaltung?
Initialisierung
Datastructure: Tree
Branching & Reintegration
Resetting
Remotes & Empfangen von Änderungen
Beheben von Konflikten
Plattformen und Lernmöglichkeiten

Yannick Baron

July 15, 2020
Tweet

More Decks by Yannick Baron

Other Decks in Technology

Transcript

  1. Clone the repository Make changes Mess things up Look at

    StackOverflow Mess things up even more “Git is easy”
  2. Clone the repository Make changes Mess things up Look at

    StackOverflow Mess things up even more Delete folder “Git is easy”
  3. Clone the repository Make changes Mess things up Look at

    StackOverflow Mess things up even more Delete folder Clone the repository “Git is easy”
  4. Clone the repository Make changes Mess things up Look at

    StackOverflow Mess things up even more Delete folder Clone the repository … “Git is easy”
  5. Using git for 12 years now Noticed very different levels

    of experience Concepts often misunderstood despite daily use I <3 git
  6. 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?
  7. 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?
  8. 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?
  9. 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
  10. 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
  11. A hierachical graph data structure Consists of nodes and edges

    Various ways of implementation fixed number of child nodes list of child nodes reference to parent node … Quick Interlude: Trees
  12. Reference to parent node Node { parent?: Node; data: any;

    } const A = new Node(); Quick Interlude: Trees A
  13. Reference to parent node Node { parent?: Node; data: any;

    } const t = new Node(); t.parent = A; A = t; Quick Interlude: Trees A
  14. Reference to parent node Node { parent?: Node; data: any;

    } const B = A; Quick Interlude: Trees A B
  15. Reference to parent node Node { parent?: Node; data: any;

    } const t = new Node(); t.parent = B; B = t; Quick Interlude: Trees B A
  16. Reference to parent node Node { parent?: Node; data: any;

    } B = undefined; Quick Interlude: Trees A
  17. 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
  18. 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
  19. 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
  20. git checkout <branch> moves HEAD to branch git diff show

    the diff of current changes --word-diff do a word diff git commit –am “<msg>” -a add all tracked files & commits Switching branches
  21. 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
  22. git init git status git add git commit git branch

    git checkout git diff git merge Recap #1
  23. 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
  24. 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!
  25. git remote add <name> <url> adds a remote repository git

    push -u <remote> <branch> push branch and setup tracking Going online for the first time
  26. 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
  27. git checkout –b <branch> -b create and switch 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
  28. git fetch download changes from the remote git checkout <branch>

    moves HEAD to branch git pull fetches and merges tracked branch into current branch git rebase <base> <branch> replay branch’s commits on top of base Receiving changes
  29. 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
  30. git log git reset git clone git remote git push

    git fetch git pull git rebase Recap #2
  31. We have seen 16 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!
  32. 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
  33. GitHub interactive Introduction https://try.github.io/ Think like a git http://think-like-a-git.net/ Watch

    this talk again https://youtu.be/S_OkNMHinlg GitHub Git Cheatsheet https://services.github.com/on- demand/downloads/github-git- cheat-sheet.pdf Resources
  34. git reset # to unstage git commit --amend git pull

    --rebase (demo) conflict when rebasing git revert git add -p git rebase –i git stash git bisect uncommit Bonus Round