KEMBAR78
DevOps Answer Bank - Module 2 | PDF | Version Control | System Software
0% found this document useful (0 votes)
7 views8 pages

DevOps Answer Bank - Module 2

The document explains the Three-tree architecture in Git, which consists of the Working directory, Staging area, and Repository, detailing how changes are made, staged, and committed. It also covers various Git commands such as commit, push, pull, fetch, and clone, highlighting their functions and differences. Additionally, it discusses advanced Git functions like stash and reset, and emphasizes the management of projects on GitHub, showcasing its collaborative features and productivity benefits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

DevOps Answer Bank - Module 2

The document explains the Three-tree architecture in Git, which consists of the Working directory, Staging area, and Repository, detailing how changes are made, staged, and committed. It also covers various Git commands such as commit, push, pull, fetch, and clone, highlighting their functions and differences. Additionally, it discusses advanced Git functions like stash and reset, and emphasizes the management of projects on GitHub, showcasing its collaborative features and productivity benefits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1. Sketch a simple Three-tree architecture in GIT.

(Explain in detail about 3-tree architecture in GIT.)

Working
 Working is the working directory where the file changes can be made.
 This is created when a git project is initialized onto the local machine, using the git init
command.
Staging
 After project changes are made, the files are staged in the staging index area using the git
add command.
 This displays the preview for the next stage.
 If further changes are made in the working directory, the snapshots of these two layers
(working & staging) will be different.
 However, these can be synced by using the same git add command.
Repository
 If no further changes are made, we can commit these changes to the repository using the
git commit command.
 This process replicates the snapshots of all three trees (working, staging, and repository),
making them in sync with each other.
2. Illustrate the GIT concepts and their architecture.
(Refer below points for Git Features and above points for Git Architecture)
 Distributed system: Git allows collaborators to access the central repository even from
around the remote corners of the world.
 Compatibility: Git is a version control system that works with all modern operating
systems like Windows, Linux, or macOS.
 Non-linear development: As git tracks the current state as a tree, we can branch and
merge at any moment and this provides capabilities for visualizing and navigating a non-
linear development history.
 Branching: Git allows us to branch out and make changes which provide easy
management of the codebase as we can merge or delete branches if required.
 Lightweight: Git uses lossless compression which compresses and stores in the local
repository, this takes little space. When data is needed, it uses the reverse procedure.
 Speed: In comparison with other VCS, Git is extremely quick and scalable, allowing
effective project management. The retrieval speed of a local repository is 100 times faster
than that of a remote server.
 Open Source: Git is a free and open-source distributed VCS (Version Control System)
that gives all features free.
 Reliable: The data of the central repository is always backed up in every collaborator’s
local repository. In case of central server crashes, the data can be quickly recovered from
collaborators.
 Secure: Git keeps track of all commits in a log file. And git stores all of the records in the
form of Hash objects using SHA1 cryptographic technology. So, if a problem emerges,
the developer can quickly identify and resolve the issue.
3. Compare GIT commit, push, pull, fetch, and clone commands.

 Git commit:
o Commit command is a process where we replicate changes made in the staging area to
the local repository.
o This process replicates the snapshots of all three trees (working, staging, and
repository), making them in sync with each other.
o Syntax: git commit –m “message”
 Git Clone:
o Cloning is the process of creating a local duplicate of your repository from the remote
repository.
o This will also sync the data between the local and remote repositories.
o Syntax: git clone <repository URL>
 Git Push:
o The act of pushing commits from your local repository to a remote repository is known
as pushing.
o Pushing has the potential to overwrite changes so caution should be exercised when
pushing.
o Syntax: git push
 Git Pull:
o Git pull is a command that allows us to fetch from and integrate with another repository
or local branch.
o Syntax: git pull origin <branch> <commit>

 Git fetch:
o Git fetch is a command that allows us to download objects from the repository.
o Syntax: git fetch
4. The GIT push command is used to transfer or push the commit, which is made on a local
branch in your computer to a remote repository like GitHub. Examine Command line to PUSH
to GitHub.
 The git push command is used to upload local repository content to a remote repository.
 Pushing has the potential to overwrite changes, so caution should be taken when pushing.
 We can push the specified branch as well along with all of the necessary commits and
internal objects using the following command.
 Syntax:
o git push <remote> <branch>
 Example to push code to GitHub:
o git push origin main
 In order to set origin, which is nothing but the remote repository like GitHub, we can use
the following command:
 git remote add origin <GitHub repo>
5. Differentiate Between the GIT Fetch and GIT Pull Commands.
 Git fetch is a command that allows us to download objects from the repository.
 Git pull is a command that allows us to fetch from and integrate with another repository
or local branch.
 We can see that a git pull is a git fetch followed by an additional action(s) – typically a
git merge.
 Git fetch is a safer alternative because it pulls the commit from your remote but doesn’t
make any changes to your local files.
 Git pull is faster as you’re performing multiple actions in one because we will introduce
changes and immediately apply them to our current branch.
 Git fetch command is used to see all remote’s changes providing more visibility about
changes giving more control over the repository.
 Syntax:
o git fetch
o git pull origin <branch> <commit>
6. GIT Merge and GIT Rebase serve the same purpose. They are designed to integrate changes
from multiple branches into one. Examine what merge and rebase are, why you should (and
shouldn’t) use them, and how to do.
 Git Merge and Rebase serve the same purpose i.e., they are designed to integrate
changes from multiple branches into one particular branch.
 The difference is, Git merge only changes the target branch. The source branch history
remains. So, this preserves the history of the source branch.
 Whereas, Git Rebase compress all the changes into a single “patch”. Then it integrates
the patch onto the target branch.
 And unlike merging, rebasing flattens history. It transfers the completed work from
source branch to target branch. In this process, the unwanted history is eliminated.
 When we are working alone or on a small team using git rebase is the best choice.
 Comparatively, when working on a big team using git merge is advisable.
7. Examine how to leverage the following advanced GIT functions: a. GIT stash b. GIT reset
 Git stash is a built-in command with the Git tool that locally stores all of the most recent
changes made to the working directory.
 Git stash acts as a mechanism to locally version files without those versions being seen
by other developers who share the same git repository.
 Git stash reverts to a previous save point, i.e., resets files in the working tree to the
previous commit point. We can use the following commands to use the git stash concept:
 git stash push
o creates a new stash and rolls back the state of all the modified files
 git stash pop
o Takes the files in a stash, places them back into the development workspace (working
directory) and deletes the stash from history.

 Git reset is similar to git stash as both commands will revert all of the files in the
working directory back to the state at the point of the previous commit.
 But, Git reset creates a new commit point in the branch history. Git stash does not.
 Git reset can jump back to any prior commit; But Git stash only resets the files in the
workspace to the point of the previous commit.
 A hard reset will discard all of the changes whereas a stash saves a snapshot of all the
locally modified files. We can use the following commands to apply Git reset concepts:
 git reset --hard HEAD
 git reset --soft HEAD
8. Narrate the methods of GitHub Management. (Cycle 1)
 GitHub describes itself as a code storage and version control tool that supports code
development cooperation.
 Each project's code is stored in Repositories, which provide us with several tools to aid us
in both the creation and administration of the project.
 Using GitHub to manage projects is rather straightforward. In reality, if you use its
components and integrations appropriately, it can make you a lot more productive.
 We know this from personal experience; it's worked for us with teams of up to 15
developers, and there's no reason it can't be expanded any higher.
 World’s best open source programs are built efficiently with the help of GitHub through
collaboration, project boards, documentation, code history, branching, and version
control.
 Not only that, GitHub has proven to be the best platform for students and engineers to
showcase their skills through projects present in GitHub projects and give an idea of the
development portfolio.

You might also like