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

t3dd16 slides: Git Fundamentals and how to succ...

Avatar for Armin Vieweg Armin Vieweg
September 02, 2016

t3dd16 slides: Git Fundamentals and how to success with PhpStorm GUI

Unfortunately no screenshots attached. The PhpStorm GUI for Git part was a live demo. Sorry.

Avatar for Armin Vieweg

Armin Vieweg

September 02, 2016
Tweet

More Decks by Armin Vieweg

Other Decks in Programming

Transcript

  1. Git Version Control System since 2005 Most popular vcs ever

    Especially because of services like GitHub Distributed System Standard in web developement Invented by Linus Torwald, who also invented Linux
  2. Installing git On Linux: sudo yum install git-all sudo apt-get

    install git-all On Mac: Git Installer available http://git-scm.com/download/mac On Windows: Git Installer available http://git-scm.com/download/win
  3. Very first step After installing git open a new command

    line interface (CLI) and enter: git config --global user.name "Jon Snow" git config --global user.email [email protected] Those infos are used for each commit you create on your system. You can overwrite git configurations by performing the command within your repository and without the --global option.
  4. Git terms Remote repository Local repository Stage Workspace All files

    in a specific folder (most likley your current project) You need to tell git which files to versionize. Those files are staged. .git directory, containing all commits, the index of commits and settings Services like GitHub or Bitbucket. Good to backup and publish your code. Supports collaboration. Commits
  5. Git processes Remote repository Local repository Stage Workspace git add

    <filename> git commit git push git pull git fetch git checkout Commits
  6. Git commit Each commit has an uuid like this: 112b577b4691786396b36aa00cf5771030604b46

    git config --global user.name "Jon Snow" git config --global user.email [email protected] Commit message git commit -m “[RELEASE] Raise version” Git just adds the changes of files (patch) to git Important to know: The order of commits does matter From 112b577 From: Armin Vieweg <[email protected]> Date: Thu, 01 Sep 2016 03:12:59 +0200 Subject: [RELEASE] Raise version This commit raises the version to 1.0 --- composer.json | 2 +- ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff ...
  7. Git Branches ❖ Branches are like “labels” assigned to commits

    ❖ Parallel branches possible ❖ Useful for workflows and collaboration ❖ Switch through branches: git checkout <branch> ❖ Create new branch: git checkout -b <newbranch> master feature/example master master master feature feature feature feature
  8. Git Merge git merge <branch> ❖ Creates merge commit ❖

    Has multiple parent commits ❖ Combines two branches ❖ Removing the branch after merging means removing the “feature/example” label from commits ❖ Commits themself remain in place, referenced by merge commit master feature/example master master master feature feature feature feature master
  9. Pull Requests Pull requests let you tell others about changes

    you've pushed to a repository. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before the changes are merged into the repository.
  10. Git Rebase git rebase ❖ Tells the first commit of

    your branch to have a different parent commit ❖ This may cause conflicts ❖ Which is good ❖ Because otherwise these conflicts would occure when performing git merge ❖ You could also use rebase instead merge to bring both branches together, but this requires a git push --force master feature/example master master master feature feature feature feature
  11. Git Rebase 2 git rebase -i ❖ Rebasing in Git

    means, manipulating Git history ❖ Interactive Rebasing allows you to modify any commits in your repository ❖ Use this to clean up non-sense commits like “fixed typo” in your feature branch, before merging ❖ You can also squash all commits together, to one [FEATURE] commit ❖ Changes in history require a git push --force ➢ Which should be prevented for important branches on remote (like master)