Common Git Commands Deployment
Benefits and Best Practices
Table of Contents
2
 Git
 Git Uses
 Git’s Functionality
 git clone
 git add
 git commit
 git checkout
 git rm
 git fetch
 git pull
 git merge
 git push
 Git refers to a system, which is meant for tracking changes to files as well as directories (a version
control system). Git records all the changes in content, and stores the history related to every change.
Repositories, which are a type of data structure, are used by Git for managing files. Repositories are
present within a specific directory. These contain the files as well as a record with regard to changes.
The multiple sets of changes that exist within a repository are separated by branches.
3
Git
 Git is usually used by software developers for managing codes. Git can be used by anyone for managing
any type of file. The flexibility of Git enables the use of Git for both, simple as well as complex projects.
Git-managed content can be configured as per one’s needs. This is made possible through multiple
branches and repositories. There are certain features in Git, which enable the viewing of information
with regard to revisions, as well as aid in finding the cause of an issue, and manipulate changes.
4
Git Uses
 The command line is used to access all of Git’s functionality. Some of its most common commands and
options are listed in the following slides.
 The information contained here isn’t comprehensive, and information about intermediate as well as
advanced Git functionality have been omitted.
5
Git’s Functionality
6
1-800-123 -8156
Whoa!That’s a big number, aren’t
you proud?
It is a command that is meant for cloning a repository into a new directory. It also creates remote-tracking
branches, as well as forks a new working branch from the active branch of the cloned repository.
 The git fetch command should be used to update the remote-tracking branches of the new repository.
 The git pull command should be used for merging the remote master branch into the current master
branch.
 The Git Version Control interface in cPanel provides the URL, which is used for cloning the
repositories of each account.
cPanel >> Home >> Files >> GitVersion Control
7
Git Clone
 This command is used for adding a file’s current version to the index of staged content for the next
commit.
 Only the current changes for the current commit are staged by this command.When a commit is
created again, the command for the file needs to be run again.This is needed to stage any new changes.
8
Git Add
 This command is meant for creating a new commit for the currently-staged changes.
 Use the git add or the git rm commands for staging changes for inclusion in a commit, or individual
filepaths can be provided as arguments to this command.
9
Git Commit
 Through this command a specified branch can be set as the current working branch.
 This command needs to be run with a file path, rather than a branch name, for the purpose of checking
out only a specified file.
 If the branch name is omitted, Git will check out that file from the current branch’s HEAD.
10
Git Checkout
 This command serves the function of removing directories or files from Git’s index, and working tree.
 The specified file should not contain uncommitted changes, if this command needs to be run.
 This command isn’t capable of retaining the file in the index, and removing it from the working tree.To
get that done, you have to use BASH’s rm command.
11
Git RM
 Branches, tags, as well as their histories are downloaded by this command from one or more
repositories.
12
Git Fetch
 This command is used for fetching and merging changes from a local branch or from a remote or local
repository. Usually, this command combines the git fetch and the git merge commands.
13
Git Pull
 This command is meant for combining the history of one or multiple commits into the current
branch’s history.
14
Git Merge
 This command is used to add the committed changes to that repository and branch, which have been
specified. A repository needs to be explicitly specified, in order to specify a branch. If a branch isn’t
specified, the command adds the changes to the current branch of the remote repository.
 The Git Version Control feature in cPanel automatically adds a post-receive hook. This is triggered by
each push to cPanel-manged repositories.
 To digress, cPanel is a web hosting control panel. Web hosting is a service provided by web hosting
companies for making websites accessible. Web hosting can be of many types. For example, terms such
as “Linux Shared Hosting”, and “Windows Shared Hosting”, refer to a type of web hosting that is
shared and Linux-based.
15
Git Push
16
Thanks!
ANY QUESTIONS?
www.htshosting.org
www.htshosting.org/best-web-hosting-company-India
www.htshosting.org/best-windows-hosting
www.htshosting.org/best-cloud-hosting-company

Common Git Commands

  • 1.
    Common Git CommandsDeployment Benefits and Best Practices
  • 2.
    Table of Contents 2 Git  Git Uses  Git’s Functionality  git clone  git add  git commit  git checkout  git rm  git fetch  git pull  git merge  git push
  • 3.
     Git refersto a system, which is meant for tracking changes to files as well as directories (a version control system). Git records all the changes in content, and stores the history related to every change. Repositories, which are a type of data structure, are used by Git for managing files. Repositories are present within a specific directory. These contain the files as well as a record with regard to changes. The multiple sets of changes that exist within a repository are separated by branches. 3 Git
  • 4.
     Git isusually used by software developers for managing codes. Git can be used by anyone for managing any type of file. The flexibility of Git enables the use of Git for both, simple as well as complex projects. Git-managed content can be configured as per one’s needs. This is made possible through multiple branches and repositories. There are certain features in Git, which enable the viewing of information with regard to revisions, as well as aid in finding the cause of an issue, and manipulate changes. 4 Git Uses
  • 5.
     The commandline is used to access all of Git’s functionality. Some of its most common commands and options are listed in the following slides.  The information contained here isn’t comprehensive, and information about intermediate as well as advanced Git functionality have been omitted. 5 Git’s Functionality
  • 6.
    6 1-800-123 -8156 Whoa!That’s abig number, aren’t you proud?
  • 7.
    It is acommand that is meant for cloning a repository into a new directory. It also creates remote-tracking branches, as well as forks a new working branch from the active branch of the cloned repository.  The git fetch command should be used to update the remote-tracking branches of the new repository.  The git pull command should be used for merging the remote master branch into the current master branch.  The Git Version Control interface in cPanel provides the URL, which is used for cloning the repositories of each account. cPanel >> Home >> Files >> GitVersion Control 7 Git Clone
  • 8.
     This commandis used for adding a file’s current version to the index of staged content for the next commit.  Only the current changes for the current commit are staged by this command.When a commit is created again, the command for the file needs to be run again.This is needed to stage any new changes. 8 Git Add
  • 9.
     This commandis meant for creating a new commit for the currently-staged changes.  Use the git add or the git rm commands for staging changes for inclusion in a commit, or individual filepaths can be provided as arguments to this command. 9 Git Commit
  • 10.
     Through thiscommand a specified branch can be set as the current working branch.  This command needs to be run with a file path, rather than a branch name, for the purpose of checking out only a specified file.  If the branch name is omitted, Git will check out that file from the current branch’s HEAD. 10 Git Checkout
  • 11.
     This commandserves the function of removing directories or files from Git’s index, and working tree.  The specified file should not contain uncommitted changes, if this command needs to be run.  This command isn’t capable of retaining the file in the index, and removing it from the working tree.To get that done, you have to use BASH’s rm command. 11 Git RM
  • 12.
     Branches, tags,as well as their histories are downloaded by this command from one or more repositories. 12 Git Fetch
  • 13.
     This commandis used for fetching and merging changes from a local branch or from a remote or local repository. Usually, this command combines the git fetch and the git merge commands. 13 Git Pull
  • 14.
     This commandis meant for combining the history of one or multiple commits into the current branch’s history. 14 Git Merge
  • 15.
     This commandis used to add the committed changes to that repository and branch, which have been specified. A repository needs to be explicitly specified, in order to specify a branch. If a branch isn’t specified, the command adds the changes to the current branch of the remote repository.  The Git Version Control feature in cPanel automatically adds a post-receive hook. This is triggered by each push to cPanel-manged repositories.  To digress, cPanel is a web hosting control panel. Web hosting is a service provided by web hosting companies for making websites accessible. Web hosting can be of many types. For example, terms such as “Linux Shared Hosting”, and “Windows Shared Hosting”, refer to a type of web hosting that is shared and Linux-based. 15 Git Push
  • 16.