Git

16
Topic: Md Ariful Islam, MCE, UDE & Prasad Bambure

Transcript of Git

Page 1: Git

Topic:

Md Ariful Islam, MCE, UDE&

Prasad Bambure

Page 2: Git

Outline

What is version control sytem? What is git? Terminology Git work flows Git branch Get going with git commands

Page 3: Git

What is version control system?

For working by yourself:- Gives you a “time machine” for going back to earlier versions- Gives you great support for different versions (standalone, web app, etc.) of

the same basic project For working with others:

- Greatly simplifies concurrent work, merging changes

Page 4: Git

What is git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency

Initially designed and developed

by Linus Torvalds for

Linux kernel development

First Released on June 15, 2005

Git used for Linux version control

Page 5: Git

What is git? Continues....

Version control systems keep track of the changes in files and directories over time.

Also,

records the history of data

acts like a time machine of data

In general:

Git allows a team of people to work together, all using the same files. And it helps the team cope with the confusion that tends to happen when multiple people are editing the same files.

There are many ways it can be set up and configured,

how we use it: when a new employee starts, he downloads all the files from Github, which is an online server we're all connected to. 

So he has his local version of the files, I have my local version, our boss has his local version, etc.

Page 6: Git

Terminology Repository

- a storage of the history of changes of thetracked files, hidden from the user

Working Copy- the set of tracked files

Revision- a specific state of data recorded in the history

Branch- a separate line of history of the trackedfiles deviating from the origin or anotherbranch

Tag- a reference to a specific state of a branch

Page 7: Git

Git workflow

Page 8: Git

Git workflow1.You MODIFY files in your working directory.

2.You STAGE the files, adding snapshots of them to your staging area.

3.You do a COMMIT, which takes the files as they are in the staging area and stores that snapshot permanently to your git directory.

Page 9: Git

What tools we need?Is git works in distributed environment?Yes, it works in windows, linux, Mac OS, Solaris etc.

Git is available as: Source file Package DistributorHere we are using bitbucket Download or setup git from here: https://git-scm.com/downloads

Page 10: Git

Git branch Two types: master and branch A branch represents an independent line of development. Branches serve as

an abstraction for the edit/stage/commit process. It comes from master  

Page 11: Git

Get going with git(how could we start) Open your git bash or terminal Steps 1) Configure git in your system 1st time git config –-global user.name “Islam, Md Ariful“ git config –-global user.email “ [email protected]“ Step 2) Clone repository git clone repository path/name.git(http/ssh) Step 3) initialization git on local cd project/or right click on repository of project git init or git init project Step 4) add remote git remote add origin path/name.git Step 5) create file touch README.txt (anyfile u could create as .js, .php)

Page 12: Git

Get going with git(how could we start) continues.. Step 6) (stage) add your new file/ add your specific modified file git add –all or git add –p path/filename Step 7) commits (its like comments that what have you done/changed) git commit –m “text of your commits/works info“ Step 8) upload your file git push origin remote_repository_name before push you need to check remote changes as: git remote update git fetch git pull origin remote_repository_name

Page 13: Git

Get going with git(how could we start) continues.. Creating branch: git branch branchname or creating from master git checkout origin master git branch –b branchname deleting branch git branch –d branchname or, git branch –D branchname (force delete) Check branches: git branch

Page 14: Git

Get going with git(how could we start) continues.. Merging updates (adding others code to yours) git merge branch1 branch2 Abort merge git merge –abort Check your work status git status (that is recommended to do always)

Page 15: Git

References:

Some of the slides are adopted from “Introduction to Git” available at http://innovationontherun.com/presentation-files/Introduction%20To%20GIT.ppt

Some of the figure are adopted from Pro GIT by Chacon, which is available at http://progit.org/book/

Some of the slides are adopted from “Git 101” available at http://assets.en.oreilly.com/1/event/45/Git%20101%20Tutorial%20Presentation.pdf

https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

Page 16: Git

?