TWS Git & Github Short Notes
TWS Git & Github Short Notes
Short Notes
FOR DEVOPS ENGINEERS
Train With
Shubham
Git & Github Short Notes
Before getting dive into Git and GitHub we've to
know some basic terminologies
There is a term Source Code Management and it has two
types:-
CVCS — Centralized Version Control System
DVCS — Distributed Version Control System
source: edureka
Note
It is not locally available, meaning we've always needed to be
connected to a network to perform any action.
Since everything is centralized, if the central server gets
failed, you will lose the entire data
[1]
Train With
Shubham
DVCS — Distributed Version Control System
Important Terms
Repository
A repository is a place where you have all your codes or kind
of folder on the server.
It is a kind of folder related to one product.
Changes are personal to that particular repository.
Server
It stores all repository
It contains metadata also
Working directory
Where you see files physically and do the modification.
At a time, you can work on a particular branch.
[3]
Train With
Shubham
Commit
Store changes in the repository. You will get one Commit-Id.
It is 40 Alpha-Numeric characters.
It uses the SHA1 checksum concept.
Even if you change one dot, Commit-Id will change.
Commit is also named the SHA-1 hash
Commit Id/Version-Id/Version
Reference to identify each change.
To identify who changed the file.
Tags
Tags assign a meaningful name with a specific version in the
repository. Once a tag is created for a particular save, even if
you create a new commit, it will not be updated.
Snapshots
Represents some date of a particular time.
It is always incremental i.e- It stores the change (append
date) only. Not the entire copy.
Push
Push operations copy changes from a local repository server to
a remote or central repository. This is used to store the
changes permanently in the git repository.
[4]
Train With
Shubham
Pull
Pull operation copies the changes from a remote repository to a
local machine. The pull operation is used for synchronization
between the repository.
[5]
Train With
Shubham
Create a new branch
Delete a branch
source: simplilearn
[6]
Train With
Shubham
When the same file has different content in different branches, if you do
merge, conflict occurs (Resolve conflict then add and commit)
The 'git diff' command helps to identify the differences between the
state's repositories or files
[7]
Train With
Shubham
The 'git checkout' command is used to undo the changes made to the file, or
for changing branches
The 'git reset --mixed' command is used to undo changes to the working
directory and staging area
The git merge --abort command helps in exiting the merge process and
returning back to the state before the merging began
The git reset command is used at the time of merge conflict to reset the
conflicted files to their original state
[8]
Train With
Shubham
Clone an existing Git Repository
[9]
Train With
Shubham
Checkout to a new branch
[10]
Train With
Shubham
Push your local changes to the remote branch
[11]
Train With
Shubham
Git Stash and pop
Git Stashing
[12]
Train With
Shubham
Git Stash Pop (Reapplying Stashed Changes)
Git allows the user to re-apply the previous commits by using the git
stash pop command. The popping option removes the changes from the
stash and applies them to your working file.
The git stash drop command is used to delete a stash from the queue.
Generally, it deletes the most recent stash.
[13]
Train With
Shubham
What is git squash?
To “squash” in Git means to combine multiple commits into one. You can
do this at any point in time (by using Git’s “Interactive Rebase”
feature), though it is most often done when merging branches.
There are different ways and tools when it comes to squashing commits.
In this post, we’ll talk about Interactive Rebase and Merge as the two
main ways to squash commits.
Step1: Check the commit history
The above command will open your default text editor and will squash the
last commits.
Step 3: update the commits
On pressing enter key, a new window of the text editor will be opened to
confirm the commit. We can edit the commit message on this screen.
[14]
Train With
Shubham
Thank You Dosto
Train With
Shubham