1. What is GIT?
GIT is a distributed version control system and source code management (SCM) system.
2. What language is used in GIT?
‘C’ language.
3. What is “Staging Area” or “Index” in GIT?
It is an intermediate area used before completing the commits, where changes can be formatted and reviewed .
4. Different commands:
git stash: takes the current state of the working directory and index and puts in on the stack for later and gives you back a clean working directory.
git stash drop: It will remove the last added stash item by default, and it can also remove a specific item if you include as an argument.
git stash apply:when you want to continue working where you have left your work.
git branch -merged: lists the branches that have been merged into the current branch
git branch -no merged: lists the branches that have not been merged
git clone: creates a copy of an existing Git repository.
git init: .git directory will be created in the project directory.
git diff : shows the changes between commits and working directory.
git status: shows the difference between the working directory and the index,.
git checkout: used to update directories or specific files in your working tree with those from another branch without merging it in the whole branch.
git rm: to remove the file from the staging area and also off your disk.
git log: To find specific commits in your project history- by author, date, content or history.
git add: adds file changes in your existing directory to your index.
git reset: to reset your index as well as the working directory to the state of your last commit.
5. What is ‘head’ in git and how many heads can be created in a repository?
A ‘head’ is simply a reference to a commit object. In every repository, there is a default head referred as “Master”. A repository can contain any number of heads.
6. What is the purpose of branching in GIT?
The purpose of branching in GIT is that you can create your own branch and jump between those branches. It will allow you to go to your previous work keeping your recent work intact.
7. How can you bring a new feature in the main branch?
Use command “git merge” or “git pull command”.
8 What is a ‘conflict’ in git?
A ‘conflict’ arises when the commit that has to be merged has some change in one place, and the current commit also has a change at the same place. Git will not be able to predict which change should take precedence.
9. How can conflict in git resolved?
To resolve the conflict in git, edit the files to fix the conflicting changes and then add the resolved files by running “git add” after that to commit the repaired merge, run “git commit”. Git remembers that you are in the middle of a merger, so it sets the parents of the commit correctly.
9. To delete a branch what is the command that is used?
To delete a branch use, the command “git branch –d [head]”.
10. What is rebasing in git?
“Rebasing” is an alternative to merging in git.
Syntax: git rebase [new-commit]
11. What is the difference between ‘git remote’ and ‘git clone’?
‘git remote add’ just creates an entry in your git config that specifies a name for a particular URL. While, ‘git clone’ creates a new git repository by copying and existing one located at the URI.
12. What is GIT version control?
It tracks the history of a collection of files and includes the functionality to revert the collection of files to another version.Each version captures a snapshot of the file system at a certain point of time.
13. What is the difference between the ‘git diff ’and ‘git status’?
‘git diff’ is similar to ‘git status’, but it shows the differences between various commits and also between the working directory and index.
14. Explain what is commit message?
Commit message is a feature of git which appears when you commit a change. Git provides you a text editor where you can enter the modifications made in commits.
15. How can you fix a broken commit?
To fix any broken commit, you will use the command “git commit—amend”. By running this command, you can fix the broken commit message in the editor.
16. Why is it advisable to create an additional commit rather than amending an existing commit?
The amend operation will destroy the state that was previously saved in a commit. If it’s just the commit message being changed then that’s not an issue. But if the contents are being amended then chances of eliminating something important remains more.
GIT is a distributed version control system and source code management (SCM) system.
2. What language is used in GIT?
‘C’ language.
3. What is “Staging Area” or “Index” in GIT?
It is an intermediate area used before completing the commits, where changes can be formatted and reviewed .
4. Different commands:
git stash: takes the current state of the working directory and index and puts in on the stack for later and gives you back a clean working directory.
git stash drop: It will remove the last added stash item by default, and it can also remove a specific item if you include as an argument.
git stash apply:when you want to continue working where you have left your work.
git branch -merged: lists the branches that have been merged into the current branch
git branch -no merged: lists the branches that have not been merged
git clone: creates a copy of an existing Git repository.
git init: .git directory will be created in the project directory.
git diff : shows the changes between commits and working directory.
git status: shows the difference between the working directory and the index,.
git checkout: used to update directories or specific files in your working tree with those from another branch without merging it in the whole branch.
git rm: to remove the file from the staging area and also off your disk.
git log: To find specific commits in your project history- by author, date, content or history.
git add: adds file changes in your existing directory to your index.
git reset: to reset your index as well as the working directory to the state of your last commit.
5. What is ‘head’ in git and how many heads can be created in a repository?
A ‘head’ is simply a reference to a commit object. In every repository, there is a default head referred as “Master”. A repository can contain any number of heads.
6. What is the purpose of branching in GIT?
The purpose of branching in GIT is that you can create your own branch and jump between those branches. It will allow you to go to your previous work keeping your recent work intact.
7. How can you bring a new feature in the main branch?
Use command “git merge” or “git pull command”.
8 What is a ‘conflict’ in git?
A ‘conflict’ arises when the commit that has to be merged has some change in one place, and the current commit also has a change at the same place. Git will not be able to predict which change should take precedence.
9. How can conflict in git resolved?
To resolve the conflict in git, edit the files to fix the conflicting changes and then add the resolved files by running “git add” after that to commit the repaired merge, run “git commit”. Git remembers that you are in the middle of a merger, so it sets the parents of the commit correctly.
9. To delete a branch what is the command that is used?
To delete a branch use, the command “git branch –d [head]”.
10. What is rebasing in git?
“Rebasing” is an alternative to merging in git.
Syntax: git rebase [new-commit]
11. What is the difference between ‘git remote’ and ‘git clone’?
‘git remote add’ just creates an entry in your git config that specifies a name for a particular URL. While, ‘git clone’ creates a new git repository by copying and existing one located at the URI.
12. What is GIT version control?
It tracks the history of a collection of files and includes the functionality to revert the collection of files to another version.Each version captures a snapshot of the file system at a certain point of time.
13. What is the difference between the ‘git diff ’and ‘git status’?
‘git diff’ is similar to ‘git status’, but it shows the differences between various commits and also between the working directory and index.
14. Explain what is commit message?
Commit message is a feature of git which appears when you commit a change. Git provides you a text editor where you can enter the modifications made in commits.
15. How can you fix a broken commit?
To fix any broken commit, you will use the command “git commit—amend”. By running this command, you can fix the broken commit message in the editor.
16. Why is it advisable to create an additional commit rather than amending an existing commit?
The amend operation will destroy the state that was previously saved in a commit. If it’s just the commit message being changed then that’s not an issue. But if the contents are being amended then chances of eliminating something important remains more.