What is a version control system (VCS)?
A VCS
What is a git repository?
A repository is a file structure where git stores all the project-based files. Git can either stores the files on the local or the remote repository.
Steps to install git
What does git clone do?
The command creates a copy (or clone) of an existing git repository. Generally, it is used to get a copy of the remote repository to the local repository.
How can you see a history of the git commits ?
git log
**git log -2 **(show just the last two commits)
How do you get rid of ‘unstaged changes’ ?
in other words, the file is being tracked by git, you have made uncommited/unstaged changes to it which you want to discard
git checkout – filename
or git checkout – . (for all the files)
or git restore filename
git checkout also used to switch branches.
How do you unstage a change ?
***git restore –staged <file>***</file>
what if you dont want to include certain files in your git repo ?
use .gitignore file
- should check in the .gitignore file so it stays with the repo
How do you delete a file ?
the delete is the same as a change. a new commit is made to reflect the deletion.
How do you create an issue ?
you can create an issue in Git by following these steps:
On GitHub.com, navigate to the main page of the repository.
Under your repository name, click Issues.
Click New issue.
What is a pull request ?
A pull request is a feature in Git that allows developers to propose changes to a codebase hosted on GitHub. It is essentially a request to merge one branch into another.
What is fork ?
A fork is a Git feature that allows you to create a copy of an existing repository. Forking a repository creates a new repository in your account that is identical to the original repository. You can then make changes to the forked repository without affecting the original repository.
What is rebase ?
A rebase is a Git command that allows you to modify the history of a branch. It works by moving the entire branch to begin on the tip of another branch. i.e. move the base of the branch to begin at the tip of another branch
What does the command git config do?
The git config command is a convenient way to set configuration options for defining the behavior of the repository, user information and preferences, git installation-based configurations, and many such things.
For example:
To set up your name and email address before using git commands, we can run the below commands:
Can you explain head in terms of git and also tell the number of heads that can be present in a repository?
What is a conflict?
What is the functionality of git ls-tree?
This command returns a tree object representation of the current repository along with the mode and the name of each item and the SHA-1 value of the blob.
What does git status command do?
git status command is used for showing the difference between the working directory and the index which is helpful for understanding git in-depth and also keep track of the tracked and non-tracked changes.
Define “Index”.
Before making commits to the changes done, the developer is given provision to format and review the files and make innovations to them. All these are done in the common area which is known as ‘Index’ or ‘Staging Area’.
What does git add command do?
these files go to Staging - they still need to be Commited
Why is it considered to be easy to work on Git?
With the help of git, developers have gained many advantages in terms of performing the development process faster and in a more efficient manner. Some of the main features of git which has made it easier to work are:
How will you create a git repository?
Tell me something about git stash?
Git stash can be used in cases where we need to switch in between branches and at the same time not wanting to lose edits in the current branch. Running the git stash command basically pushes the current working directory state and index to the stack for future use and thereby providing a clean working directory for other tasks
What is the command to create a branch ?
***git branch <branch-name>***</branch-name>