git and fundamentals

29
GIT Fundamentals & Features Presenter: Naincy Gupta Mindfire Solutions

Upload: naincy-gupta

Post on 20-Jan-2017

188 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Git and fundamentals

GIT Fundamentals & Features

Presenter: Naincy GuptaMindfire Solutions

Page 2: Git and fundamentals

About Me Certifications:M70 101 - Magento Certified DeveloperOCA 870 - MYSQL

Contact Me: Email: [email protected]: mfsi_naincy.gupta

Connect Me: -Facebook : https://www.facebook.com/naincy.gupta.35574LinkedIn : in.linkedin.com/pub/naincy-gupta/66/440/6a3/Google+: https://plus.google.com/u/0/+NaincyGuptaTechSharing/postsBlog: http://[email protected]

Page 3: Git and fundamentals

Contents GIT Types of VCS Basic Fundamentals GIT Usage Workflows of GIT GIT Stash Code Quality Why GIT make you happy?

Page 4: Git and fundamentals

Git is nothing but a SCM tool. 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.

Git is easy to learn and has a tiny footprint with lightning fast performance.

Page 5: Git and fundamentals
Page 6: Git and fundamentals
Page 7: Git and fundamentals

Centralized Distributed

Central, authoritative repository Everyone has its own repository

All changes saved in one single location Get safety without having worry about 'breaking the build'

Client-Server approach One can change in repository and those changes will be local to them unless they synchronize with someone else.

Page 8: Git and fundamentals

Is this true?

Page 9: Git and fundamentals
Page 10: Git and fundamentals

Start with GIT Install GIT client

- sudo apt-get install git (linux)

- brew install git (MAC)

Check if git is installed or not

$ git –version

Set username and email to your git config

$ git config --global user.name “Naincy”

$ git config --global user.email “[email protected]

$ git config –list (will allow you to verify the username and email)

Page 11: Git and fundamentals

GIT Fundamentals

Creating a repository (if it does not exist remotely)

$ git init (follow http://git-scm.com/docs/git-init for more information)

Cloning a remote repository:

$ git clone http[s]://host.xz[:port]/path/to/repo.git/

(Inspecting a repo: $ vim .git/config)

Page 12: Git and fundamentals

Inspecting repo:

$ git status [Difference b/w index file and current head commit]

$ git log [Sow list of all commit with commit message]

$ git log -1 [Show top 1st commit]

$ git log - -pretty=oneline [Show list of all commit in single line]

Page 13: Git and fundamentals

Branch Operations:

$ git branch <branch_name> OR git checkout -b <branch_name>

[will create new branch for you]

$ git branch -D <bramch_name> [allows you to delete branch]

$ git branch -m <old_branch_name> <new_branch_name> [will

remane the branch name from old to new]

$ git checkout <branch_name> [allows to switch to other branch]

$ git log - -pretty=oneline [Show list of all commit in single line]

Page 14: Git and fundamentals

Making edit and commiting

$ git diff [will show delta difference code of current master HEAD and current index]

$ git status [will show path of file as “Changes not staged for commit”]

$ git add (-A) [will show file as “Changes to be commited”]

$ git commit -m [write your commit message. Save and exit] {file changed,

insertion, deletion}

Check your commit by $ git log

Send changes to server

$ git push <branch_name> [will push your all local changes to the server]

$ git pull <branch_name> [will pull all changes from server to your local]

Page 15: Git and fundamentals
Page 16: Git and fundamentals

Recover your changes that you have added by mistakes

$ git add <file name> [file <file name> that you have added by mistake]

$ git status

$ git reset HEAD <filename>

$ git checkout - - <filename>

Merge one branch to another

$ git merge branch2 [you are in branch 1 and merging branch2]

If you get conflicts, then can resolve with mergetool which provides a GUI interface to resolve

conflicts.

$ git mergetool

Page 17: Git and fundamentals

GIT WorkFlows

Page 18: Git and fundamentals
Page 19: Git and fundamentals
Page 20: Git and fundamentals
Page 21: Git and fundamentals

GIT Stash

Will allow you to save your changes without commiting them

$ git stash save 'message' [save your change as a seperte stash@{*}

branch with commit message]

$ git stash list [will show you list of all stash with commit message]

$ git show <stash@{0}>

[will show you what code difference contain this this stash@{0}]

$ git apply <stash@{0}> [will allow to apply change in current branch]

Page 22: Git and fundamentals

Code Quality

Page 23: Git and fundamentals
Page 24: Git and fundamentals
Page 25: Git and fundamentals
Page 26: Git and fundamentals

Fast and Compact

Freedom and Safety

Explore and Understand

Control and Assemble

Enforce Discipline: manages process by which control of items passes from one another.

Archive Version: can store subsequent versions of source control items. Also maintain lot of historical data like author, date, time, etc.

Enable Collaboration: easy sharing of files and docs Recover from accidental deletion: can easily swith to

working copy.

Page 27: Git and fundamentals
Page 28: Git and fundamentals

QUESTIONS..??

Mail me your questions at [email protected]

Page 29: Git and fundamentals

Thank You..!!