0% found this document useful (0 votes)
46 views45 pages

Git A - Z: Version Controller System

Uploaded by

saidaback
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)
46 views45 pages

Git A - Z: Version Controller System

Uploaded by

saidaback
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/ 45

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 config user.email


The git config user.email command is used to display the email
address associated with the user who made the commits in the Git
repository.

$ git config --local user.email


[email protected]
The git config --local user.email command is used to set the email address
associated with the user who made the commits in the Git repository at the
local repository level.
$ git config --local --remove-section user
The git config --local --remove-section user command is used to remove the
[user] section from the local Git repository configuration file.

$ 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.

$git help init


The git help init command is used to display the manual page for the git init
command, which is used to create a new Git repository.
$ git add index.html
The git add command is used to add changes made to a file or files to the
Git staging area, which is the first step in committing changes to a Git
repository. In your example, you are using the git add command to add the
changes made to the index.html file to the staging area.

$git commit m-"index.html"


$ git add .
The git add . command is used to add all changes made in the current
directory and its subdirectories to the Git staging area. The . (dot)
represents the current directory, so running git add . will add all files and
changes made in the current directory and its subdirectories to the staging
area.
The git diff command is used to show the differences between two versions of
a file, or between two commits in a Git repository. When you run the git diff
command, Git will show you the differences between the files in the working
directory (i.e., the current state of the files on your local machine) and the files
in the Git repository.
$ git cat-file 208299eedf2bb4bd91e8f8a2ffa8308fcc401811 -p
The git cat-file command is a Git command used to view the contents of a
Git object. This command can be used to display the contents of a specific
Git object, such as a commit, tag, or blob, and can be helpful in
troubleshooting Git repositories or examining the history of a project.
$ mv Example.txt newFile.txt
The command "mv Example.txt newFile.txt" would rename the file
"Example.txt" to "newFile.txt". The contents of the file would remain the
same, but it would now be accessible using the new name.
Branch
How to remove branch
The git branch -d feat-1-ranil command is used to delete the branch named
feat-1-ranil. However, in this case, the branch deletion was not successful and
returned an error message stating that the branch is not fully merged.

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.

Octopus merge: This type of merge is used to combine three or more


branches simultaneously. In an octopus merge, Git combines the changes
from all branches into a single commit that is applied to the main branch.
This is useful when you have multiple feature branches that depend on each
other and need to be merged together.
How to update commit new commit
Git Cloaning
SSH cloning
Generating a new SSH key

Adding your SSH key to the ssh-agent


After modify as you
want
Upstream
Read me File
Collabration
fork

Create organization

Cherry pick
revert

Reset

You might also like