getting started on distributed version control with git

34
A NOOP T HOMAS M ATHEW CTO @ Profoundis Inc. Getting Started with git

Upload: anoop-thomas-mathew

Post on 06-May-2015

547 views

Category:

Engineering


3 download

DESCRIPTION

Learn how to use git and get accustomed with 15+ most common git commands.

TRANSCRIPT

Page 1: Getting Started on distributed version control with git

ANOOP THOMAS MATHEWCTO @ Profoundis Inc.

Getting Started with git

Page 2: Getting Started on distributed version control with git

A Little Story

April 2005

Linux Kernel

BitKeeper issue

Linus Torvalds 36% professional developers

@atmb4u

Page 3: Getting Started on distributed version control with git

Need for Distributed Version Control

Meet Smarty!

He works as a Software Developer.

@atmb4u

Page 4: Getting Started on distributed version control with git

Need for Distributed Version Control

● His job– Create– Save– Edit– Repeat.

● Smarty's friends want to collaborate?

@atmb4u

Page 5: Getting Started on distributed version control with git

Need for Distributed Version Control

@atmb4u

Page 6: Getting Started on distributed version control with git

git Basics

● Distributed● Collaborative History Tracking● Merge● Flexible● Fast

@atmb4u

Page 7: Getting Started on distributed version control with git

git workflow

@atmb4u

Page 8: Getting Started on distributed version control with git

git workflow

@atmb4u

1. 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: Getting Started on distributed version control with git

git Basics

@atmb4u

Page 10: Getting Started on distributed version control with git

@atmb4u@atmb4u

git commands

Page 11: Getting Started on distributed version control with git

● git config --global user.name "UserName"● git config --global user.email “[email protected]

git config

@atmb4u@atmb4u

Page 12: Getting Started on distributed version control with git

initialize a git repository on current folder

git init

@atmb4u

Page 13: Getting Started on distributed version control with git

Retrives the status of the git repository

git status

@atmb4u

Page 14: Getting Started on distributed version control with git

● Adds the file to the version control● git add <filename>

git add

@atmb4u

Page 15: Getting Started on distributed version control with git

● Commit the added changes to the repo● git commit -m “commit message”

git commit

@atmb4u

Page 16: Getting Started on distributed version control with git

● Add a remote server location for the repo● git remote add origin <remote url>● git remote rm origin

git remote

@atmb4u

Page 17: Getting Started on distributed version control with git

● Push changes to the destination● git push origin master

remote branch

git push

@atmb4u

Page 18: Getting Started on distributed version control with git

● Shows the history of commits of the current branch

git log

@atmb4u

Page 19: Getting Started on distributed version control with git

● Shows the difference between two commits in git● git diff 23f4af3 09fb5f2● Writing this to a file gives you a patch

git diff

@atmb4u

Page 20: Getting Started on distributed version control with git

● Include all changes specified in a patch file● git apply <patch file>

git apply

@atmb4u

Page 21: Getting Started on distributed version control with git

● download new branches and data from a remote repository

git fetch

@atmb4u

Page 22: Getting Started on distributed version control with git

● fetch from a remote repo and try to merge into the current branch

● git pull <remote location> <branch>

git pull

@atmb4u

Page 23: Getting Started on distributed version control with git

● list, create and manage working contexts● git branch● git branch <branch name>

(create new branch)

git branch

@atmb4u

Page 24: Getting Started on distributed version control with git

● switch to a new branch context● git checkout <branch name>● git checkout -b <branch name>

(create branch and checkout)

git checkout

@atmb4u

Page 25: Getting Started on distributed version control with git

● merge a branch context into your current one

● git merge

git merge

@atmb4u

Page 26: Getting Started on distributed version control with git

Merge conflicts !

@atmb4u

Page 27: Getting Started on distributed version control with git

● tag a point in history as important● git tag -a v1.0

git tag

@atmb4u

Page 28: Getting Started on distributed version control with git

● remove files from the staging area● git rm <file name>● git rm –cached <file name>

git rm

@atmb4u

Page 29: Getting Started on distributed version control with git

● save changes in the current index and working directory for later

● git stash● git stash apply● git stash list● git stash drop

git stash

@atmb4u

Page 30: Getting Started on distributed version control with git

● save changes in the current index and working directory for later

● git reset HEAD <file name>● git reset --soft● git reset HEAD --hard

git reset

@atmb4u

Page 31: Getting Started on distributed version control with git

● copy a git repository so you can add to it● git clone <remote repo url>

git clone

@atmb4u

Page 32: Getting Started on distributed version control with git

● github● Learn a language of choice● Commit once a day

Live Projects

@atmb4u

Page 33: Getting Started on distributed version control with git

Code Explorer's Guideto the Open Source Jungle

https://leanpub.com/opensourcebook/

My new Book

@atmb4u

FREE

Page 34: Getting Started on distributed version control with git

● @atmb4u● We are looking for interns.

Thank You !

@atmb4u