Git A - Z: Version Controller System
Git A - Z: Version Controller System
Prasad Karunanayaka
In a CVCS, there is a central repository that holds the latest version of the
codebase. Developers check out code from this central repository, make
changes, and then check their changes back in. The central repository is the
authoritative source for the codebase, and all changes are made directly to
it.
In contrast, a DVCS allows each developer to have their own copy of the
codebase, complete with its full history. Developers make changes to their
local copy of the code, and then push those changes to a central repository
or pull changes from other developers' repositories. The central repository
in a DVCS is just one of many copies of the codebase.
Sementic version
Git configuration allows you to customize your Git
environment by setting various parameters such as your
name, email address, default editor, and more.
$ git config --list --show-origin
The git config --list --show-origin command shows the Git configuration
values along with the file they were read from.
$ git init
The git init command is used to create a new Git repository. When you run
git init in a directory, it creates a new subdirectory named .git that
contains all the necessary files for a Git repository.
$ ls
The ls command is used to list the files and directories in the current
working directory. When you run ls in a terminal or command prompt, it will
show you a list of all the files and directories in the current directory.
$ git status
The git status command is used to show the current state of the Git
repository. When you run this command in the terminal or command
prompt, it will show you information about the branch you are currently on,
any changes that have been made to files in the repository, and any
changes that have been staged or are waiting to be committed.
This means that there are some changes in the branch feat-1-ranil that have
not been merged into the branch you are currently on. Git is designed to
prevent accidental deletion of unmerged changes, so it throws an error
message to warn you that deleting the branch would result in losing unmerged
changes.
To delete the branch despite the unmerged changes, Git provides the -D flag
as a more forceful option. When you ran git branch -D feat-1-ranil, Git deleted
the branch feat-1-ranil without checking whether it was fully merged into the
current branch.
The message "Deleted branch feat-1-ranil (was b92fda3)" indicates that the
branch feat-1-ranil was successfully deleted and that it was pointing to the
commit with the hash b92fda3.
Git supports different types of merge operations, depending on the
branching and merging strategies used. Here are some of the most common
types of merge in Git:
Fast-forward merge: This is the simplest and most common type of merge.
It occurs when the branch you want to merge into has progressed since the
creation of the branch you want to merge. In this case, Git simply moves the
branch pointer forward to match the pointer of the branch being merged.
This results in a linear history without any additional commit or merge
nodes.
Recursive merge: This type of merge occurs when the branch being merged
contains commits that are not in the current branch, and the two branches
have diverged. In this case, Git creates a new merge commit that combines
the changes from both branches. The merge commit has two or more
parent commits, and it creates a new merge node in the commit history.
Squash merge: This type of merge combines the changes from a feature
branch into a single commit that is then applied to the main branch. It is
useful when you want to keep the commit history clean and avoid merge
commits cluttering the commit log. In a squash merge, Git combines all
changes from the feature branch into a single commit that is applied on top
of the main branch.
Create organization
Cherry pick
revert
Reset