diff --git a/topics/git/README.md b/topics/git/README.md index 9a10cf1..3beb8a9 100644 --- a/topics/git/README.md +++ b/topics/git/README.md @@ -14,21 +14,27 @@
How do you know if a certain directory is a git repository?
- You can check if there is a ".git" directory. -
+ +
-Explain the following: git directory, working directory and staging area
+Explain the following: git directory, working directory and staging area
+ This answer taken from [git-scm.com](https://git-scm.com/book/en/v1/Getting-Started-Git-Basics#_the_three_states) -"The Git directory is where Git stores the meta data and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer. +"The Git directory is where Git stores the meta-data and object database for your project. This is the most important +part of Git, and it is what is copied when you clone a repository from another computer. -The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. +The working directory is a single checkout of one version of the project. These files are pulled out of the compressed +database in the Git directory and placed on disk for you to use or modify. -The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area." -
+The staging area is a simple file, generally contained in your Git directory, that stores information about what will go +into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging +area." + +
What is the difference between git pull and git fetch?
@@ -46,20 +52,22 @@ a separate branch in your local repository How to check if a file is tracked and if not, then track it?
There are different ways to check whether a file is tracked or not: - -- `git ls-files ` -> exit code of 0 means it's tracked -- `git blame ` + - `git ls-files ` -> exit code of 0 means it's tracked + - `git blame ` ... -
+ +
Explain what the file gitignore is used for
-
+The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached. + +
How can you see which changes have done before committing them?
- `git diff` +
@@ -72,7 +80,8 @@ There are different ways to check whether a file is tracked or not: You've created new files in your repository. How to make sure Git tracks them?
`git add FILES` -
+ + ### Scenarios @@ -130,13 +139,14 @@ True
You have two branches - main and devel. How do you make sure devel is in sync with main?
- + ``` git checkout main git pull git checkout devel git merge main ``` +
@@ -237,6 +247,7 @@ Using the `git rebase` command
In what situations are you using git rebase?
Suppose a team is working on a `feature` branch that is coming from the `main` branch of the repo. At a point, where the feature development is done, and finally we wish to merge the feature branch into the main branch without keeping the history of the commits made in the feature branch, a `git rebase` will be helpful. +