Presentation is loading. Please wait.

Presentation is loading. Please wait.

om om GIT - Tips & Tricks / git.dvcs git-tips.com

Similar presentations


Presentation on theme: "om om GIT - Tips & Tricks / git.dvcs git-tips.com"— Presentation transcript:

1

2

3

4 nirgeier@gmail.c om nirgeier@gmail.c om GIT - Tips & Tricks / git.dvcs git-tips.com www.linkedin.com/in/nirgeier @nirgeier

5

6 What is non-linear is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows.

7

8

9 History 1972 - SCSS Closed source Save original file Save snapshot of changes To get the latest version get version 1 add version 2 add version 3.... Work only on single file

10 History 1982 - RCS Open source Cross platform Save latest version as most recent and changes are applied backward Much faster then SCSS Work only on single file

11 History 1986-1990 - CVS Work on multiple file Remote repository Allow Concurrent users to work at same time on same file(s) Capture changes to every single file Shared work

12 History 1999 - BitKeeper Closed source Used for the linux kernel 2002-2005 DVCS (Distributed Version Control) Stopped to be free in 2005

13 History 2000- SVN Faster then CVS Allowed saving binary data (images etc) Capture changes not on only to files or group of files but to whole directory. Takes a snapshot of the directory and not the files Shared work Can track file renames

14 April 2005

15 Born April 2005 Up to 200x faster then SVN DVCS Integrity check (SHA1) Branches are free Cross platform Compact love have You love it or have it

16 Why developers hate GIT CLI - most of the work needs to be done from command line Very Complex (thousands !!! of command options) git-config.html git-log.html git-config.html git-log.html Hard to learn Merge can be nightmare [5 different merge strategies !!!][5 different merge strategies !!!] Fast forward vs Not fast forward

17 Small example: Question: Is git case sensitive ? How does it handle case sensitive renamed files?Answer: Do Not !!! Try it at home ( * git mv)

18 Key Features

19 DVCS The Three States Hashes Change sets / snapshots Branches Fast forward vs Non fast forward Merge / Rebase

20 (DVCS) Key Features (DVCS) No need for central repository No network in needed = we can work offline Faster - no date needs to be sent to server (SVN: lock) Each copy it a full repo Each repository can be unique (contain its own change sets) Branches (Local) Reliability - no server down time or corrupted data

21 (3 states) Key Features (3 states) http://ndpsoftware.com/git-cheatsheet.html

22 (snapshots) Key Features (snapshots) CVS/SVN use deltas calculate With long histories, becomes heavy to calculate current files state

23 (snapshots) Key Features (snapshots) git all your files snapshot Every time you commit, or save the state of your project in git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.

24 (snapshots) Key Features (snapshots)

25 Hands On

26 Installing

27 Installing http://git-scm.com/downloads Windows: download installer Mac (pre installed with OS) Unix – sudo apt-get update sudo apt-get install git

28 Configuration

29 .gitconfig

30 .gitconfig Git has 3 configuration levels System Global (User) Project

31 .gitconfig The configuration fall into two categories client side server side

32 .gitconfig The command is git config Project level: git config user.name "Nir Geier" Global level: git config --global user.name "Nir Geier" System level: git config --system user.name "Nir Geier"

33 .gitconfig (initial configuration) $ git config --global user.name “Nir Geier” Sets the name you want attached to your commits $ git config --global user.email “nirgeier@gmail.com” Sets the email you want attached to your commis $ git config --global color.ui auto Enables helpful colorization of command line output

34 .gitconfig.gitconfig [ alias ] Same as Unix aliases – execute long commands using shortcut

35 .gitconfig.gitconfig [ alias ] Aliases can be simple or complicated Simple alias: ls = git log --oneline

36 .gitconfig.gitconfig [ alias ] Aliases can be a custom function ra = "!f() { git remote add $1 https://bitbucket.org/$2.git; }; f"

37 .gitconfig.gitconfig [ alias ] complex function : "!bash -c ‘source ~/.githelpers && pretty_git_log’ "

38 .gitignore

39 .gitignore Git can be configured to ignore certain files and directories..gitignore This is configured in a.gitignore file. This file can be in any directory and can contain patterns for files. *.class ex: *.class.gitignore is parsed in a commutative way from top to bottom (system /global / root folder/ inner folder)

40 .gitignore Note (1): --force git add --force [filename] You can still add ignored files to the staging area of the Git repository by using the --force parameter, i.e. git add --force [filename] command.

41 .gitignore Note (2): Files that are committed to the Git repository are not automatically removed if you add them to a.gitignore file. You can use the git rm -r --cached [filename] command to remove existing files from a Git repository.

42 .gitkeep

43 Commands

44 Most common commands git init / clone git status git add git rm git commit git checkout git log

45 git init

46 Starting new project: git init [--bare] *git flow init Joining existing project (Fetching remote repository): git clone http://......./repo.git

47 git status

48 Display the working tree status 1.Differences between the index file and the current HEAD commit. 2.Differences between the working tree and the index untracked files.

49 git status

50 git add

51 Before Before committing change to a git repository you need to mark the changes that should be committed. This is done by adding the new and changed files to the staging area. snapshot This creates a snapshot of the affected files.

52 git add Note: In case you change one of the files again before committing, you need to add it again to the staging area to commit the new changes. git add. git add -A.

53 git rm

54 Remove files from the index, or from the working tree and the index. If you delete a file which is under version control, git add. does not record this file deletion. You can use the git rm command to delete the file from your working tree and record the deletion of the file in the staging area.

55 git rm

56 git commit

57 Add the stages files to the local repository git commit git commit -m git commit -am git commit --amend

58 git checkout

59 Checkout a branch or paths to the working tree When used on files/paths = discard changes

60 nirgeier@gmail.c om nirgeier@gmail.c om GIT - Tips & Tricks / git.dvcs git-tips.com www.linkedin.com/in/nirgeier @nirgeier


Download ppt "om om GIT - Tips & Tricks / git.dvcs git-tips.com"

Similar presentations


Ads by Google