git commd
git commd
GIT fetch – It downloads only the new data from the remote repository and does not
integrate any of the downloaded data into your working files. Providing a view of
the data is
all it does.
GIT pull – It downloads as well as merges the data from the remote repository into
the local
working files.
This may also lead to merging conflicts if the user’s local changes are not yet
committed.
Using the “GIT stash” command hides the local changes.
Question: What is Git fork? How to create tag?
A fork is a copy of a repository. Forking a repository allows you to freely
experiment with
changes without affecting the original project.
A fork is really a Github (not Git) construct to store a clone of the repo in your
user account.
As a clone, it will contain all the branches in the main repo at the time you made
the fork.
38/71
Create Tag:
Click the releases link on our repository page.
Click on Create a new release or Draft a new release.
Fill out the form fields, then click Publish release at the bottom.
After you create your tag on GitHub, you might want to fetch it into your local
repository too: git fetch.
Question: What is difference between fork and branch?
A fork is a copy of a repository. Forking a repository allows you to freely
experiment with
changes without affecting the original project.
A fork is really a Github (not Git) construct to store a clone of the repo in your
user account.
As a clone, it will contain all the branches in the main repo at the time you made
the fork.
Question: What Is Cherry Picking In GIT?
Cherry picking in git means to choose a commit from one branch and apply it onto
another.
This is in contrast with other ways such as merge and rebase which normally applies
many
commits onto a another branch.
Make sure you are on the branch you want apply the commit to. git checkout master
Execute the following:
git cherry-pick <commit-hash>
Question: What Language GIT Is Written In?
Much of Git is written in C, along with some BASH scripts for UI wrappers and other
bits.
Question: How To Rebase Master In GIT?
Rebasing is the process of moving a branch to a new base commit. The golden rule of
git
rebase is to never use it on public branches.
The only way to synchronize the two master branches is to merge them back together,
resulting in an extra merge commit and two sets of commits that contain the same
changes.
Question: What is ‘head’ in git and how many heads can be created in a
repository?
39/71
There can be any number of heads in a GIT repository. By default there is one head
known
as HEAD in each repository in GIT.
HEAD is a ref (reference) to the currently checked out commit. In normal states,
it's actually
a symbolic ref to the branch user has checked out.
if you look at the contents of .git/HEAD you'll see something like "ref:
refs/heads/master".
The branch itself is a reference to the commit at the tip of the branch
Question: Name some GIT commands and also
explain their functions?
Here are some most important GIT commands
GIT diff – It shows the changes between commits, commits and working tree.
GIT status – It shows the difference between working directories and index.
GIT stash applies – It is used to bring back the saved changes on the working
directory.
GIT rm – It removes the files from the staging area and also of the disk.
GIT log – It is used to find the specific commit in the history.
GIT add – It adds file changes in the existing directory to the index.
GIT reset – It is used to reset the index and as well as the working directory to
the
state of the last commit.
GIT checkout – It is used to update the directories of the working tree with those
from another branch without merging.
GIT Is tree – It represents a tree object including the mode and the name of each
item.
GIT instaweb – It automatically directs a web browser and runs the web server with
an interface into your local repository.
Question: What is a “conflict” in GIT and how is it resolved?
When a commit that has to be merged has some
changes in one place, which also has the changes
of current commit, then the conflict arises.
The GIT will not be able to predict which change will
take the precedence. In order to resolve the conflict
in GIT: we have to edit the files to fix the conflicting
changes and then add the resolved files by running
the “GIT add” command; later on, to commit the
40/71
repaired merge run the “GIT commit” command. GIT
identifies the position and sets the parents of the
commit correctly.