Git & GitHub §Have you met octocat? §Petr Svihlik - 2015 -Why git? OS tools on GH, MVC -Agenda, timescope -Level/for whom? Git - a distributed version control system •In centralized systems, every developer is a node working more or less equally on a central hub. •In Git, however, every developer is potentially both a node and a hub •Distributed doesn‘t mean that there is no central repository. There is always a repo that is in a way leading or considered as a „reference“ (called „blessed“ in the figure below). •https://git-scm.com/book/no-nb/v1/Distributed-Git-Distributed-Workflows - §Git & GitHub -Comparison with TFS -TFS limitations in collaboration -Different branching/merging scenarios Git – the three states •File can be: •Commited – stored safely in a local repo database (in git directory) •Modified – changed = differs from version that has been checked out (in a working directory) •Staged – marked to go to the next commit (in staging area aka index) •https://git-scm.com/book/en/v1/Getting-Started-Git-Basics §Git & GitHub Git – staging in Team Explorer §Git & GitHub § Git – Checkout §Each repository can have multiple branches. We switch between them using „git checkout“ command. § §Git & GitHub § § § - TFS vs Git checkout Git - remotes •Remote repositories are versions of your project that are hosted on the Internet or network somewhere. •You can have several of them, each of which generally is either read-only or read/write for you. •This is what allows you to collaborate •https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes §Git & GitHub § § Git(Hub) – Pull requests •PRs allow you to promote your changes to repositories you don‘t have write access to •You are basically requesting the maintainer of the repository to pull your changes •Based on commands: •git request-pull - takes the base branch into which you want your topic branch pulled and the Git repository URL you want them to pull from, and outputs a summary of all the changes •->Make sure you create a branch for each topic/feature – it‘s easier to maintain (merge) them. •git pull - Fetch from and integrate with another repository or a local branch •git pull does a git fetch followed by a git merge •GitHub has its own Pull Request mechanism • § §https://git-scm.com/book/tr/v2/Distributed-Git-Contributing-to-a-Project §Git & GitHub § § § Git – Fitting together §Git & GitHub § § § § Git – Getting a repo (Init, Clone, Fork) §Init – creates an empty repo out of a folder §Clone – Copies a repository and sets its „remotes“ to the original repo §Fork – Clones a repo server-side. Not a Git command. More info: http://stackoverflow.com/a/6286877/1332034 § § §https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository §Git & GitHub § § § Git – Using command line from VS •Sometimes, especially when performing advanced operations (such as syncing a fork) there‘s no other way than doing it via command line. •In order to do that you need to install 3rd party Git cmd prompt tools. §Git & GitHub § § § -VS OOTB support of git from VS2013 -GitHub desktop Git – Upstream vs Origin •upstream generally refers to the original repo that you have forked •origin is your fork: your own repo on GitHub, clone of the original repo of GitHub •upstream and origin are aliases on your local machine for particular repositories • • •More info: http://stackoverflow.com/questions/9257533/what-is-the-difference-between-origin-and-upstream-in-gi thub •http://stackoverflow.com/questions/9529497/what-is-origin-in-git • • §Git & GitHub - Just explain terminology GitHub – Creating your first pull request •Don‘t be afraid! http://firstpr.me/ + The Myth of the Genius Programmer •Step-by-step manual on confluence •Sign-in to GH •Go to KInspector and Fork it •Clone the repository to your local machine •Open the solution and do some changes •Go to changes and hit Commit & Sync •Go to GitHub and • • §Git & GitHub § § § § GitHub UI Walkthrough Show some accounts at firstpr.me Go step-by-step References •http://git-scm.com/ •https://help.github.com/ • §Git & GitHub § § § [USEMAP] Author §Follow me: •https://twitter.com/PetrSvihlik •https://github.com/petrsvihlik •http://stackoverflow.com/users/1332034/rocky •http://devnet.kentico.com/users/225882/petr-svihlik • § §Git & GitHub § § § §