Slide 1

Slide 1 text

Version controlling WITH

Slide 2

Slide 2 text

NISHAN CHATHURANGA Software Engineer 99X Technology (Pvt) Ltd. University of Moratuwa Faculty of Information Technology

Slide 3

Slide 3 text

Version control systems are a category of software tools that help a software team manage changes to source code over time. Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members. What is version control

Slide 4

Slide 4 text

By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. What is Git

Slide 5

Slide 5 text

For us to share and work collaboratively with other developers, we require access to a Git-based hosted service. • GitHub • Bitbucket • GitLab • Microsoft Visual Studio Team Services Git can be accessed and managed using command line tools. There are graphical User Interface (GUI) clients such as • Git extensions • Source tree • Tortoise Git

Slide 6

Slide 6 text

GitHub, Inc. is a United States-based global company that provides hosting for software development version control using Git. It is a subsidiary of Microsoft What is Github

Slide 7

Slide 7 text

changes server changes checkout changes changes changes changes origin It’s not necessary to have a central location to store all the versions of a project, instead developers and programmers copy (called clone) the main project to their local hard drive, so everyone has a physical mirrored copy of it to work on.

Slide 8

Slide 8 text

On your mark ! Git set !! Go !!! DEMO

Slide 9

Slide 9 text

Create a repo Go to Github.com -> Click on + -> Click on `New Repository` -> Give repository name -> Click `Create repository`

Slide 10

Slide 10 text

> git init > git remote add origin -- do your changes -- > git add . > git commit -m "first commit" > git push -u origin master

Slide 11

Slide 11 text

changes YourRepo origin > git clone -- do your changes -- > git add . > git commit -m "initial commit" > git push –u origin master Clone a repo 1 2 3

Slide 12

Slide 12 text

changes you / repo origin forking upstream fork someone / repo 1 2 3 4 pull request (PR) 5

Slide 13

Slide 13 text

changes you / repo origin forking upstream fork someone / repo 1 2 3 5 pull request (PR) 6 4

Slide 14

Slide 14 text

> git clone -- do your changes -- > git add . > git commit -m "initial commit" -- add upstream url, get changes from upstream -- > git remote add upstream > git fetch upstream --all > //git pull > git push –u origin master

Slide 15

Slide 15 text

Branches > git branch //lists all branches > git branch //create new > git checkout //switch to > git checkout -b //create + switch

Slide 16

Slide 16 text

merge > git checkout master //switch to > git merge new-feature //merge new-feature to master > git branch -d new-feature //delete new-feature

Slide 17

Slide 17 text

Merge conflict <<<<<<< HEAD this is some content to mess with content to append ======= totally different content to merge later >>>>>>> new_branch_to_merge_later $ git merge new_branch_to_merge_later Auto-merging merge.txt CONFLICT (content): Merge conflict in mer ge.txt Automatic merge failed; fix conflicts and then commit the result. File > < terminal

Slide 18

Slide 18 text

rebase > git checkout master > git merge feature > git checkout feature > git rebase master Merge vs rebase

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

GIT terminology Branch A version of the repository that diverges from the main working project. Repository A repository is a folder whose contents are tracked by git. It is also known as a repo, in simple terms. Master The primary branch of all repositories. All committed and accepted changes should be on the master branch. You can work directly from the master branch, or create other branches. Clone A clone is a copy of a repository or the action of copying a repository. Commit Adding/saving the changes to the local repository

Slide 21

Slide 21 text

HEAD HEAD is a reference variable used to denote the most current commit of the repository in which you are working. When you add a new commit, HEAD will then become that new commit. Push Updates a remote branch with the commits made to the current branch. You are literally “pushing” your changes onto the remote. Rebase When rebasing a git commit, you can split the commit, move it, squash it if unwanted, or effectively combine two branches that have diverged from one another. Merge Taking the changes from one branch and adding them into another (traditionally master) branch.

Slide 22

Slide 22 text

Thank you https://forms.gle/BXwy52z1cDXqyGpn6 Please provide your feedback at https://github.com/fossmora/gitdemo Some useful links