1. What is Git?
- It is a distributed version control command-line tool (Tracks changes of files locally and remotely)
- Most useful for projects with multiple people
- track changes in any set of files
- Updated files behave like unique “snapshots”
- Main advantages of Git are support for distributed systems, data integrity, speed and non-linear workflows.
2. What is GITHUB?
- Git is a version control system
- Hub is the website github.com, where developers can store and share their projects over the web with likeminded people.
- Each project is saved in a repository (repo)
- Before you can collaborate in a repo, you must first be a part of it by cloning the repo.
3.What is Gitlab?
GitLab is a web-based Git-repository manager with wiki, issue-tracking and CI/CD pipeline features. GitLab is a single application for the entire software development lifecycle. Gitlab is written in RUBY.
What is the difference between GIT, GITHUB and GITLAB ?
- Git is a distributed version control command-line tool.
- GITHUB is a web based hosting platform based out of GIT. That mean project development can be publicly shared with the people or store it in the repository and anyone can clone the project to make use of it.
- There is a privately hosted GITHUB but it is paid version.
GITLAB is also web based platform but it contains some extra features like built in CI/CD , AUTO CI, Issue tracker, built-in wiki. It contains built-in authentication features by using which we restrict the usage of certain features.
4. What is difference between SVN and GIT?
- SVN is installed in one central servers and using clients it can be accessible (non-distribute VCS).
- GIT is distributed when the user clone the repository then user will get the complete copy of the repository.
- Anytime the data can be merged with the source machine.
- In GIT content will be stored as metadata where as in SVN content will be stored as files.
- SVN have global revision number.
The content in GIT is hashed using cryptographically which used SHA1 algorithm for encryption. This feature helps in protecting the contents from repository corruption taking place due to network issues or disk failures.
5. What is merge conflicts have you faced ever in your experience? If you face how you resolve?
When developers work on the same piece of code and when they tried to push the code to the central repository then it will throw merge conflicts. We have to check the issue in git status and open the file in editor to resolve the conflicts before pushing to the repository.
6. What is git stash?
Imagine you’re in the middle of working on a new feature, and an emergency arises on something else which you need to fix immediately. You may not want to commit your unfinished work because it’s in a messy state. You could create a new workspace for the hot fix and clone the repo into it, but that’s a heavyweight approach (you’d be getting the entire repo again). Git provides a lightweight alternative with the “git stash” command, which temporarily removes your changes and saves them until you bring them back later.
Stashing Uncommitted Changes
The following command temporarily hides your current file modifications in your working directory and saves them until you bring them back later:
This command gives you a clean working directory. You’re now able to switch to a new branch to make your important updates, without having to commit a meaningless snapshot just to save your current state.
Once you’re done working on the fix and want to go back to your previous changes again, all you need to do is run “git stash pop”:
git stash pop
This command will recover your stashed changes.
If you no need of those changes and want to clear the stash stack you can do so with “git stash drop”:
git stash drop
7. What is Git Head?
Git will always point to the latest commit in the master which is called HEAD.
8. What is staging in GIT?
After Add and before committing the area is called as staging area. Its ready to the commit.
9. What is the difference between Fetch, pull and clone?
- git Fetch – it is similar to pull which fetches the remote code and updates only changes.
- git Pull – pull the code from remote and merge with the local copy
- git Clone – it is entire copy of the repo
- git rebase – It saves the current branch which is not in upstream branch to temporary location and keep the current branch to same as you started the changes.
- git pull -rebase will pull all the remote changes, rewind your local branch, replay your changes over the top of your current branch one by one till you are up to date
10. What is the purpose of the .gitignore file? What is the purpose of it?
To make your life easier (ideally) by telling git not to track some files in your local repository.
Git sees all files in your working directory as: