GIT Flashcards

1
Q

What type of version control do you use?

A

we use git for version control, it is very important in development, even when working alone, it protects us from making mistakes. If error happens, it’s easy to return to known working code version. It gives a more flexible environment on code without worrying about irreversibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Git?

A

It’s used for managing and tracking changes in source code. It’s designed for both small and large projects, it helps to create efficient collaboration and quick handling of project versions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the function of the git clone?

A

this command makes a copy of a Git repository. It’s the common way for programmers to get a duplicate of a remote repository.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the function of ‘git config’?

A

this command is used for configuring the Git installation. We can use it to define various settings such as repository behavior, user information, and preferences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a ‘conflict’ in Git?

A

It happens when the commit to be merged has a modification in the same location as the current commit. Git can’t automatically decide which change should be prioritized in that location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Git repository?

A

Git repository refers to a place where all the Git files are stored. These files can be stored in the local repository or the remote repository.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you create a repository in Git?

A

to create a repository, we create a directory for the project, if it doesn’t exist, we run the command “git init”. By running this command .git directory will be created in the project directory, the directory doesn’t need to be empty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you resolve ‘conflict’ in Git?

A

first, we identify the conflicted files, then we make the preferred changes in those files, we add changes using the git add command, and finally, commit the changes with git commit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is ‘git status’ used for?

A

It shows the difference between the working directory and the index, it helps understand a git more widely.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain Git Workflow?

A

In GIT, developers use three main areas: the Working Directory (where we edit files), the Staging Area (where changes are prepared for the next update), and the GIT Repository (where finalized changes are stored with project history).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the advantages of using Git?

A

It has several advantages, including data redundancy and replication, suitability for various projects, high availability, a single .git directory per repository, effective disk utilization and network performance, and collaboration-friendly features.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the commands for your version control?

A

We configure our username and email address using git config. We add one or more files to the staging area with git add. To view the changes made to a file, we use git diff. Checking the state of the working directory and staging area is done with git status. When we want to save our changes to the local repository, we use git commit. Uploading local repository content to a remote repository is achieved through git push. Lastly, to fetch and download content from a remote repository and immediately update the local repository to match, we use git pull.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the difference between local vs remote repositories? (Git vs GitHub)

A

Git manages our local repository, while GitHub (or other remotes) serves as a platform for hosting and collaborating, enabling synchronization with a centralized location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between commit and push?

A

git commit “records changes to the repository” , git push “updates remote repository”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Git stash?

A

git stash temporarily shelves changes for later use, we can add a message with git stash save "<message>", check stashes with git stash list, and reapply a specific stash using git stash apply stash@{index number}.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Git stash drop?

A

This command removes a specific stash item. If we no longer need a particular stash, like stash@{abc}, we can use the command `git stash drop stash@{abc} to delete from the list.

17
Q

How do you see who updated the class file using GIT?

A

Using “git log” command. Git logs allow to review and read the history of everything that happens to a repository.

18
Q

What is staging in GIT?

A

The staging area, or “index” in Git, is file that tracks changes for next commit. In the Git workflow, we modify files, selectively stage changes we want in the next commit, and commit to store those changes permanently in Git directory.

19
Q

Simple rules for less merge conflicts

A

Daily, use “git pull” to update our master branch with the latest changes from web repositories. Merging the master branch into our active branch ensures it stays current, short-lived branches is to reduce the risk of merge conflicts. Long-lived branches may lead to conflicts if multiple developers change the same code. Short-lived branches merged back into the master branch quickly, minimizing conflicts due to less code to consider. Following to the Single Responsibility Principle and using small, modular classes lower the chance of conflicts. This is, part of SOLID software design, improves code quality. Effective communication with team members is crucial. Knowing each other’s tasks helps avoid simultaneous changes to the same code, decreasing conflicts. In case another developer try to modify the same code we working on, collaboration is a must