Git Training

Git Training

What is Git? andWhy Git? Git Installation &Tools Git in Action
File Status Lifecycle Cloning and Commits Git Transfer Protocols Pushing & Pulling Branching & Merging
Customizing Git GitWorkflow
flowing with Features flowing with Releases flowing with Hotfixes
Git Migration from SVN Projects

9121bbd9f3feb1f85dacef76f626c049?s=128

Walid El Sayed Aly

February 24, 2017
Tweet

Transcript

  1. GIT TRAINING a true team player! @welsayedaly! GIT AT 1&1

  2. TOPICS 1. What is Git? and Why Git? 2. Installation

    & Tools 3. Git in Action • File Status Lifecycle • Cloning and Commits • Git Transfer Protocols • Pushing & Pulling • Branching & Merging 4. Customizing Git 5. Git Workflow • flowing with Features • flowing with Releases • flowing with Hotfixes 6. Migration from SVN Projects !
  3. WHAT & WHY GIT? 1

  4. Git is a distributed revision control and source code management

    system
  5. Linus Torvalds Git was designed and developed by Linus Torvalds

    in 2005
  6. None
  7. None
  8. Git is faster than SVN

  9. Git treats data like a set of snapshots of a

    mini file system SVN stores the changes made to each file over time
  10. Git uses signal thread for commits Multi threads for cloning,

    pulling and fetching of data $ git config --global pack.threads „number“
  11. None
  12. with Git the code is always with you

  13. INSTALLATION ! & ! TOOLS 2

  14. Windows: https://git-scm.com/download/win ! Linux: apt-get install git ! Mac: https://git-scm.com/download/mac

  15. GIT TOOLS On Windows: TortoiseGit: https://tortoisegit.org

  16. GIT TOOLS on Windows: sourceTree: https://www.sourcetreeapp.com

  17. GIT TOOLS On Linux: SmartGit: http://www.syntevo.com/smartgit/

  18. GIT TOOLS On Linux: ! gitg: ! http://bit.ly/MrssYM

  19. GIT TOOLS On Mac: SourceTree: https://www.sourcetreeapp.com

  20. GIT MANAGEMENT TOOLS Management front-end tools: Bitbucket: https://bitbucket.org/! Gitorious gitorious.org!

    Gitlab: gitlab.org! GitHub Enterprise enterprise.github.com!
  21. GIT MERGE TOOLS Git mergetool: git mergetool [--tool=<tool>] [-y |

    --[no-]prompt] [<file>…]
  22. GIT MERGE TOOLS Meld:

  23. GIT IN ACTION 3

  24. File Status Lifecycle GIT BASICS

  25. Create a new repository: GIT BASICS $ git init $

    git init <projectName> $ git init --bare <projectName>
  26. Cloning a repository: GIT BASICS $ git clone <Repo> $

    git clone <Repo> <projectName>
  27. GIT TRANSFER PROTOCOL PROTOCOL PRO CONTRA local protocol git clone

    /opt/ app.git - simple! - use existing file permissions - shared access difficult! - mount/remote desk need SSH protocol git clone ssh:// user@server:app. git - secure! - authentication easy to setup - people need to access! GIT protocol git clone git:// server/app.git - fastest protocol! - everybody can read, secure - no authentication! - need git-daemon-export-ok file on the server! HTTP(S) protocol git clone http(s)// server/app.git - easy to setup! - read only over https - long time to clone, fetch files! - more network overhead
  28. Creating/modifying (new) files: GIT BASICS $ git add <fileName> $

    git add . $ git add *
  29. Committing changes: GIT BASICS $ git commit -m <message> $

    git commit -am <message>
  30. Pushing your changes: GIT BASICS $ git push <remote> <branchName>

    $ git push <remote> --all
  31. Pulling changes from remote: GIT BASICS $ git pull <remote>

    $ git pull --rebase <remote>
  32. Branching: GIT BASICS $ git branch $ git branch <newBranch>

    $ git branch -a
  33. Branching: GIT BASICS $ git branch -d <branchName> $ git

    checkout <branchName> $ git checkout -b <newBranch>
  34. Branching: GIT BASICS $ git push <remote> <branchName>

  35. Merging Branches: GIT BASICS $ git merge <branchName>

  36. Tagging: GIT BASICS $ git tag $ git tag -l

    comet-4* $ git tag -a <newTag> -m <message> $ git tag -s <newTag> -m <message>
  37. Tagging: GIT BASICS $ git push origin --tags $ git

    push origin <tagName>
  38. Tagging: GIT BASICS $ git checkout -b <BS-4711> <tagName>

  39. Checking the Status: GIT BASICS $ git status

  40. Logging: GIT BASICS $ git log $ git log --since=

    2.weeks $ git last $ git log -n <limit> $ git log --author <name>
  41. DEMO

  42. CUSTOMIZING GIT 4

  43. CUSTOMIZING GIT $ git config --global <option> <value> $ git

    config --list
  44. CUSTOMIZING GIT description value user.name set up user name walid.elsayedaly

    user.email set up email me@me.com core.editor set up your editor vim/Notepad++ color.ui set up your color true
  45. CUSTOMIZING GIT description value color.branch! color.diff! color.interactive! color.status specify your

    color red, blue credential.helper! (since git-1.9) caching credential cache! timeout=400 user.signingkey set up your key path path to the key commit.template set up a template $/home/template.txt
  46. CUSTOMIZING GIT description value diff specify your merge tool path

    to the merge tool http ssl verify sslVerify = true/ false
  47. CUSTOMIZING GIT IGNORE FILES .gitignore // explisit every project .gitignore_global

    // ${HOME} global for all projects
  48. CUSTOMIZING GIT Adding Remote Repository: $ git remote add comet

    git://serverName/app.git $ git fetch comet
  49. Aliases: alias.ac = !git add -A && git commit $

    git config --global alias.<name> <value> $ git ac -m <message>
  50. Git and Scrum $ git config --global alias.scrum <scrumValue> scrum

    = !git log --author=walid --since‘1 day ago‘ --until= ,now‘ $ git scrum
  51. GIT ! WORKFLOW 5

  52. Git workflow is a strict branching model, aimed at the

    seamless delivery of releases Workflow approach to keep only the stable code in the “master” branch
  53. GIT WORKFLOW @ 1&1 BITBUCKET SERVER Bitbucket Server makes it

    easy to branch workflows Branch naming prefixes: • feature • release • bugfix • hotfix ! ! feature/
  54. • Git-Flow simplifies the development of large projects ! •

    Install it from: https:// github.com/nvie/gitflow ! • Git-Flow is just a wrapper around existing Git commands
  55. GIT-FLOW (FEATURE BRANCHES)! • start Git-Flow with: $ git flow

    init • new feature branch with: $ git flow feature start clgscm-7411 • finish development on the feature with: $ git flow feature finish clgscm-7411 • after that your changes will be merged automatically to the master branch and the feature branch will be deleted
  56. GIT-FLOW (VERSIONED RELEASES)! • start a new release branch with:

    $git flow release start 0.0.1 • finish development on the release with: $git flow release finish 0.0.1 • what will happen after that? 1 your changes will be merged automatically to the master II your changes from the developing branch will be also merged to the master III and you will get a new tag !
  57. GIT-FLOW (HOTFIXING ON PRODUCTION )! • start a new hotfix

    branch with: $git flow hotfix start bs-5544 • finish development on the hotfix with: $git flow hotfix finish 0.0.1 • what will happen after that? 1 your hotfix will be merged to the develop branch II your hotfix will be merged to your master III you will get a new tag IV your hotfix branch will be deleted
  58. • With Git-Flow it is easy to manage your flow

    • Git-Flow works also with existing Git-Repo, you just add git init flow to the existing Git-Repo • more information on: • https://confluence.atlassian.com/display/ BitbucketServer043/Using+branches+in +Bitbucket+Server • http://jeffkreeftmeijer.com/2010/why-arent-you- using-git-flow/
  59. GIT WORKFLOW DEMO

  60. MIGRATION FROM SVN PROJECTS 6

  61. GIT SVN

  62. I Migrating SVN Repo with subGit: - subGit is a

    tool for migrating svn repo to git - Install it from http://www.subgit.com/ - and with: subgit configure --svn-url https://svn.1and1.org/svn/crm/new-svn/ comet/application/framework/
  63. II Migrating SVN Repo with Git clone: - git svn

    clone http://my-project.googlecode.com/svn/ \ --authors-file=users.txt --no-metadata -s my_project -
  64. Join 1&1 at GitHub

  65. RESOURCES ! Git Cheat Sheet: git-tower.com/blog/git-cheat-sheet-detail/ Git Documentation : git-scm.com/documentation

    Git with other systems: jaxenter.de/artikel/Git-ein-wahrer-Teamplayer-164409 !
  66. None
  67. THANK YOU