13
Git Basics

Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Embed Size (px)

Citation preview

Page 1: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Git Basics

Page 2: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Git stores data as snapshots of the project over time

When commit• Save all the files• If files have not changed, point to the previous identical file

• To be more efficient • Create a ID to reference the commit

• ID=SHA1

Page 3: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Other SCM systems

Other systems tend to store data as changes to a base version of each file.

Page 4: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Initializing a Repository in an Existing Directory

• Create a folder• Inside the folder• $ git init

Page 5: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

.git Folder

• Init command creates .git folder

• Local repository• Invisible folder• To display

invisible folders $ ls -la

Page 6: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Inside .git folder

$ ls –l .git

Page 7: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Your Identity• Keep tracking of who worked

on the code• Name• Email• Example

$ git config --global user.name "John Doe" $ git config --global user.email [email protected]

• Identify is save in .gitconfig– Under the home foler

Page 8: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Cat .gitconfig

• Show the configuration information

Page 9: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical
Page 10: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical
Page 11: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Adding and Committing

Page 12: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Staging Area

Before and after git add

Page 13: Git Basics. Git stores data as snapshots of the project over time When commit Save all the files If files have not changed, point to the previous identical

Recover files from .git

• You can recover them from .git (local repository)

• After deleting files from working directory