GIT Flashcards
What type of version control do you use?
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.
What is Git?
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.
What is the function of the git clone?
this command makes a copy of a Git repository. It’s the common way for programmers to get a duplicate of a remote repository.
What is the function of ‘git config’?
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.
What is a ‘conflict’ in Git?
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.
What is a Git repository?
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 can you create a repository in Git?
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 do you resolve ‘conflict’ in Git?
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
.
What is ‘git status’ used for?
It shows the difference between the working directory and the index, it helps understand a git more widely.
Explain Git Workflow?
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).
What are the advantages of using Git?
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.
What are the commands for your version control?
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
.
What is the difference between local vs remote repositories? (Git vs GitHub)
Git manages our local repository, while GitHub (or other remotes) serves as a platform for hosting and collaborating, enabling synchronization with a centralized location.
What is the difference between commit and push?
git commit “records changes to the repository” , git push “updates remote repository”
What is Git stash?
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}
.