Git is a version control system of distributed nature that is used to track changes in source code during software development. It is used for coordinating work among developers in project. It can also be used to track changes in any set of files. The main objectives of Git are speed, data integrity, and support for distributed, non-linear workflows.
GitHub is a Git repository hosting service, plus it adds many of its own features. GitHub provides a Web-based graphical interface. It also provides access control and several collaboration features, basic task management tools for every project.
2) What are the benefits of using Version Control System?
a) With the Version Control System(VCS), all the team members can work freely on any file at any time. VCS gives the flexibility to merge all the changes into a common location.
b) All the previous versions and variants are neatly packed up inside the VCS. We can request any version at any time as per our requirement and we will have a snapshot of the complete project right at hand.
c) Whenever we save a new version of our project, our VCS requires a short description of the changes that we have made. Additionally, we can see what changes are made in the file’s content. This helps us to know what changes have been made in the project and by whom and when those changes were made.
d) A distributed VCS like Git allows all the team members to have a complete history of the project so if there is a breakdown in the central server you can use any of your teammate’s local Git repository.
3) Explain GIT commands ?
git add --a
git commit -m 'msg'
4) What is Git Repository ?
Git Repository is a place where we will store/maintain our project source code.
We can 2 types of repositories in git hub
1) Public Repository (Every body can see, we choose who can commit)
2) Private Repository (We choose who can see and who can commit)
Note: For every project we will create one git repository.
5) What is a clone in GitHub?
Cloning in a GitHub repository is nothing but taking project from git hub central repository to our local repository.
> git clone
6) What are the commands that you use to write a commit message?
git commit -m 'msg' is used to write commit message
Note: Commit message represents why we are commiting this change to git repository
7) Explain briefly about GIT stash?
GIT stash is used when there is a need of storing the current changes available in working tree to temporary space and work on other changes due to priority. Once priority changes completed then user can get old changes back from temporary space.
8) What is the purpose of GIT status ?
git status command is used to list down stated and un-staged files in working tree
9) What is the difference between staged and un-staged file ?
staged file means it is eligible for commit
un-staged file means which is modified in local but not eligible for commit.
Note: To commit changes we have to stage it using git add
10) What are the advantages of using the GitHub repository?
The following are the few advantages of using the GitHub repository;
a) Provides high availability
b) Easy Collaboration tool
c) Distributed version control
d) Quality open source project
e) Security, Git is designed specially to maintain the integrity of source code
11) What are the languages used in GitHub?
GitHub is a fast tool and ‘C’ language makes this possible by reducing the overhead of runtime associates with the higher programming language.
12) What is the role of “Git push”?
The “Git push” command is used for pushing changes from local repository to central repository.
13) What is the role of “Git pull"?
The “Git pull command is used for taking latest changes from central repository to local repository
14) How to un-stage the file which is in staging area?
Using git reset command we can un-stage the file
15) What is commit-id in git ?
When we do commit in git it will generate one unique id with 40 characters length to differentiate one commit with another commit. Using commit-id we can identify what all changes committed to git repository.
16) How to remove a file from git repository ?
To remove a file from git repository we can use "git rm" command.
17) What are branches in git hub?
Git branches are used to maintain multiple code bases in the project like 'develop', 'qa', 'uat', 'release', 'playground' etc.
'master' branch is the main & default branch in git repository
'develop' branch is used for all developers code integration
'qa' branch used for providing code for system integration testing (SIT)
'uat' branch used for providing code for user acceptance testing (UAT)
'release' branch used for production release
'playground' branch used for experiments
18) What is branch locking?
When we release code to SIT or UAT or PROD we will lock the branch so that nobody can commit changes to that branch so that existing functionality or code will not be disturbed.
19) What is branch merging ?
Merging changes from one branch to another branch is called as branch merging. For example we have done changes in develop branch and tested then we can merge the code from develop branch to master branch.
Note: We will use "pull request" for branch merging.
20) Have you ever faced problems with branches merging ?
Yes, while merging code from one branch to another branch i have faced conflicts and i resolved conflicts then i merged my code from develop branch to master branch.
21) What is the GIT stash drop?
git stash drop command is used to remove all stashes available in git.
22) What is "git log" and when you can use it?
The Git log command is used to find the history of commits happend in git repository. Using that history we can identify who, when, why & what changed in git repository.
23) What is a ‘conflict’ in a GIT repository?
When we are pushing/merging changes to git repository there is a chance of getting git conflicts.
Git can handle most merges on its own with automatic merging features. A conflict arises when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other. Conflicts will most likely happen when working in a team environment.
24) How to resolve a conflict in Git?
The following steps will resolve conflict in Git
Identify the files that have caused the conflicts
a) Make the necessary changes in the files so that conflict does not arise again
b) Add these files to staging using git add . command
c) Commit the changed file(s- using "git commit" command
25) How to compare files in git?
To compare files we can use "git diff" command
26) What is the purpose of ‘git config’?
Git uses your username to associate commits with an identity. The git config command can be used to set your user-name and email-id.
Suppose you want to give a username and email id to associate a commit with an identity so that you can know who has made a particular commit
git config –global user.name “Your Name”: This command will add a username.
git config –global user.email “Your E-mail Address”: This command will add an email id.
27) Which client software you are using to interact with git repository?
We have several client software's to interact with git repository
Git Tortoise etc.
28) How do you revert a commit that has already been pushed to central repository ?
There are approaches to handle this scenario
Approach-1 : Remove or edit the changes in the file in a new commit and then push it to the remote repository. This is the most obvious way to fix an error. Once we have made required changes then commit that file to the remote repository using : git commit -m “commit message”Also, you can create a new commit that undoes all changes that were made in the bad commit.
29) What is the difference between git pull and git fetch?
Git pull command pulls new changes or commits from a particular branch from your central repository and updates your target branch in your local repository.
Git fetch is also used for the same purpose but it works in a slightly different way. When you perform a git fetch, it pulls all new commits from the desired branch and stores it in a new branch in your local repository. If you want to reflect these changes in your target branch, git fetch must be followed with a git merge.
Your target branch will only be updated after merging the target branch and fetched branch. Just to make it easy for you, remember the equation below:
Git pull = git fetch + git merge
30) What is the difference between git pull and git clone ?
"git clone" is used to take entire project from central repository to local repository
"git pull" is used to take only latest changes/commits from central repository to local repository