Understanding Git: An Overview of Version Control Systems

Slide Note
Embed
Share

Git is a powerful version control system that facilitates collaborative work and maintains a comprehensive history of project changes. It offers both Centralized and Decentralized/Distributed systems, with advantages and drawbacks for each. Centralized systems rely on a central server for collaboration, while Distributed systems allow for offline work and enhanced productivity. Git repositories track files and folders under version control, aiding in efficient project management.


Uploaded on Oct 08, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to git 1

  2. Introduction to Git Version Control System Version Control System (VCS) is a software which helps the members of the software development team to work collaboratively and maintain a complete history of their work. 2

  3. Introduction to Git Types of Version Control Systems There are two broad categories of version control systems: Centralized Version Control System (CVCS) and Decentralized or Distributed Version Control System (DVCS) 3

  4. Introduction to Git Centralized Version Control System (CVCS) In Centralized Version Control System (CVCS), team collaboration is enabled through centralized server system for storing and modifying the files which are part of the same project. Drawbacks of CVCS The major drawback of CVCS is single point of failure. If the central server goes down, the team collaboration is temporarily halted. Even worse, if the proper backup is not taken and the disk of the central server gets corrupt, the entire work is lost. 4

  5. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Decentralized or Distributed Version Control System (DVCS) enables team collaboration by creating a clone of a repository on the local machine and synching the remote and local repositories by pushing and committing the changes as and when required which means, the team collaborator can still work with the local copy during server down time or network failure. can freeze the work with the remote repository once the server is up and running or network connection is established, as the case may be. 5

  6. Introduction to Git Decentralized or Distributed Version Control System (DVCS) since every collaborator is working offline most of the time and connecting to the central server only for pushing and committing the changes, the development time decreases leading to productivity enhancement. the network connection is only required during the following two cases: o for pulling latest changes to the client o for publishing changes on the central server. During rest of the time, the user can work offline employing a dedicated machine. 6

  7. Introduction to Git Git Repository The set of files and folders which are monitored by the version control system is referred to as repository . It is virtual storage of a project. It is the data structure used by VCS for storing complete information including history of a project. In essence, Git repository is a directory hosting all project files along with their metadata. 7

  8. Introduction to Git Features of Git The salient features of Version Control System are enumerated below: 1. It enables the members of software development team to work collaboratively on a single project. 2. It enables maintaining the history of every version of their work. 3. It does not allow overwriting each other s changes. 4. It enables tracking changes made to different files of a repository which may include one of the following: a. Creating a file in a repository b. Creating a folder in a repository c. Modifying an existing file in a repository. d. Moving a file from one folder to another e. Deleting a file from a repository f. Deleting a folder from a repository. g. Synchronization of local repository with remote repository using pull and push operations. 8

  9. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies Local Repository Every version control system provides a local copy of the remote repository on the client machine which enables the developer to work with his private work place. Developers work in their private workspace and after comitting, the changes become the part of a remote repository. Once committed, the changes can be viewed by other members of a project team by pulling the remote repository in their working tree. Git provides the copy of an entire repository where the user can perform any one of the changes before committing them to the remote repository 9

  10. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies Staging Area The staging area is also referred to as index or cache . It is an invisible data structure which stores the files to be committed in a special Git-compressed format. In contrast to the file in the commit, the file in the index or staging area can be modified. Git caches the files in the staging area as a measure towards performance boosting which helps in making Git faster. The two salient features which make Git faster compared to other similar version control system are: Index holds ready to commit files. Index is cached 10

  11. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies Untracked Vs Tracked Files The files in the working directory are not tracked by Git and hence are referred to as untracked files . On the other hand, the files in the staging area are tracked by Git for final commit and are referred to as tracked files . The prime steps involved in publishing a file in a Git repository are as follows: The user creates a file in his working directory. The file is then moved to the staging area using git add command. The file is finally moved to the Git local repository using git commit command. The local repository is synchronized with the remote repository using git push command. 11

  12. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies 12

  13. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies 13

  14. Introduction to Git Decentralized or Distributed Version Control System (DVCS) Terminologies Hash Code Hash code is a cryptographic checksum of the complete contents of the commit. Hence, the commit once generated cannot be changed since changing anything would change the checksum, resulting in a different commit. The files stored in the commit are read-only which are stored in a special Git compressed form. 14

  15. Introduction to Git Overview of Git Data Structure HEAD HEAD is a pointer to the latest commit. It is also referred to as master . Tree In Git, a folder is represented by a tree. A tree contains files which are Git BLOBs and other subfolders represented by trees which results in a nested tree structure. Tree is an object, which represents a directory in a working area. It holds BLOBs as well as other sub-directories. A tree is a binary file that stores references to BLOBs and trees which are also named as SHA1 hash of the tree object. 15

  16. Introduction to Git Overview of Git Data Structure Branch A branch is created to work on a new module or feature of a project. By default every Git repository has a master branch. Once the module is successfully implemented, the new branch is merged with the master branch and the new branch is deleted. Tag A specific version of a repository is represented by a tag which is normally created for product releases. Tags are immutable which means once the tag is created it cannot be modified. Hence, if a tag is created for a particular commit, it remains intact even after new commit. 16

  17. Introduction to Git Overview of Git Data Structure Clone The clone operation creates the complete copy of the repository. Pull The pull operation synchronizes the local repository with the remote repository. It copies the entire changes from the remote repository to the local repository. Push The push operation is reverse of pull operation which synchronizes the remote repository with the local repository. It copies the entire changes from the local repository to the remote repository. After successful push operation other members of a team can view the changes by issuing clone command. 17

  18. Introduction to Git Git Life Cycle The prominent steps involved in Git workflow are enumerated below: Git repository is cloned as a working copy. The user works with the working copy by adding, modifying and deleting files. The changes are added to the staging area. The changes are committed after reviewing them. Finally, the changes are pushed to the remote repository to make them part of remote repository. If something is found wrong after committing, the last commit can be corrected and the changes can be pushed to the repository. 18

  19. Introduction to Git Git Life Cycle 19

  20. Introduction to Git Installing Git on Windows For installing Git on Windows platform, download the official build of Git available on the Git website. Open any browser and enter the following URL in the address bar of a browser, https://git-scm.com/download/win Download will automatically start as demonstrated in the following figure. The name of executable file for Git for 64-bit platform is , Git-2.22.0-64-bit.exe 20

  21. Introduction to Git Installing Git on Windows 21

  22. Introduction to Git Installing Git on Windows Click on Next button to continue installation. The default location where Git is installed is C:\Program Files\Git . Accept the default location or click on the Browse button to select the required location in the file system for installing Git. 22

  23. Introduction to Git Installing Git on Windows The next screen allows you to install the required components. Accept the default selections and click on Next button to proceed to a next screen. 23

  24. Introduction to Git Installing Git on Windows Git Bash is a command line interface for using Git on Windows platform which provides features to run automated scripts. All the commands will be executed in Git Bash shell. 24

  25. Introduction to Git Installing Git on Windows Alternately, right-click in any folder to launch git bash as shown in the following figure. The shortcut menu lists the option, Git Bash Here . For launching Git GUI select the option, Git GUI Here . 25

  26. Introduction to Git Installing Git on Windows Selecting the Git Bash Here command from the shortcut menu will launch Git Bash terminal from where you can enter commands for performing various Git operations. For having a quick glance at some common Git commands, enter the following command in Git Bash. git help 26

  27. Introduction to Git Customizing Git Environment git config Command git config command supports --global' option to set up global configuration applicable to all users and all repositories existing on the target machine. The --global' option, if omitted, the configuration is applicable to the current user and the current working directory. Syntax for using git config command is shown below: Syntax: git config --global <key> <value> git config --global user.name pgn git config --global user.email pgnaik@siberindia.edu.in 27

  28. Introduction to Git Customizing Git Environment Viewing a Specific Key in a Configuration File The following command is used for viewing a value stored in a specific key in a configuration file. git config <key> Which Unsetting Config Parameter The config parameter can be unset using the following syntax: Syntax: git config [--global] unset <key> where, <key> is the name of the config parameter to be unset. h returns the value corresponding to the specified key. 28

  29. Introduction to Git Customizing Git Environment Listing Configuration Details of the Identity The command for listing the configuration details of the identity is: git config --list 29

  30. Introduction to Git Exploring Local Git Repository Local Git Repository Git repository is a folder where all the data of our project will be stored. It can be located on a local machine or a remote machine. Difference Between Normal Folder and Git Repository Normal folder contains only files and directories whereas Git repository cotains files and directories along with their complete history. Creating Git Repository on a Local Machine For creating a Git repository on a local machine, follow the steps enumerated below: 1. Start Git Bash 2. Create a folder for Git repository. 3. Convert a folder into a Git repository. 30

  31. Introduction to Git Exploring Local Git Repository How to make a folder a Git repository git init command Syntax: git init [<repository_name>] This command converts the current directory into an empty Git repository. This is an initial mandatory step in creating a repository. After the execution of this command, other commands for adding files to the repository and committing become meaningful. This command is used to start a new repository. On successful execution of the command, a .git folder containing subfolders and templates are created in the working directory. 31

  32. Introduction to Git Exploring Local Git Repository Move to that folder and enter the command: mkdir myproject cd myproject git init ls a C:/Users/student/myproject/.git is the path where the Git repository is created on the local machine 32

  33. Introduction to Git Exploring Local Git Repository On execution of git init command, the folder with the name .git is created in the current working directory as shown in the following figure. .git is a hidden folder inside myproject directory as shown in the following figure. Deleting the .git folder will delete the entire repository. 33

  34. Introduction to Git Exploring Local Git Repository The following figure displays the contents of .git folder. 34

  35. Introduction to Git Exploring Local Git Repository HEAD Pointer Another important file in .git folder is HEAD which stores a reference to HEAD pointer. The content of a file C:\Users\Lenovo1\myproject\.git\HEAD 35

  36. Introduction to Git Exploring Local Git Repository To view the value stored in a HEAD pointer or a master open the file C:\Users\Lenovo1\myproject\.git\refs\heads\master in any editor. The following content is displayed. 36

  37. Introduction to Git Exploring Local Git Repository Alternately, the HEAD pointer can be viewed from Git Bash shell by issuing the following command cat .git/refs/heads/master as depicted in the following figure which displays the same content. 37

Related