Upload
naincy-gupta
View
183
Download
1
Embed Size (px)
Citation preview
GIT Fundamentals & Features
Presenter: Naincy GuptaMindfire Solutions
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]
Contents GIT Types of VCS Basic Fundamentals GIT Usage Workflows of GIT GIT Stash Code Quality Why GIT make you happy?
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.
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.
Is this true?
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)
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)
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]
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]
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]
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
GIT WorkFlows
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]
Code Quality
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.
QUESTIONS..??
Mail me your questions at [email protected]
Thank You..!!