Git Fundamentals Flashcards
Q: What is Git?
A: Git is a distributed version control system that tracks changes in source code during software development.
Q: What is a repository in Git?
A: A repository (repo) is a directory that stores your project files and the history of changes tracked by Git.
Q: How do you initialise a Git repository?
A: Use the command git init to create a new Git repository in the current directory.
Q: What command is used to check the status of a Git repository?
A: Use git status to display the current state of the repository, including staged and unstaged changes.
Q: What is a commit in Git?
A: A commit is a snapshot of the changes in your repository. It represents a specific point in the project’s history.
Q: How do you stage changes in Git?
A: Use git add <file> to stage changes or git add . to stage all changes in the current directory.</file>
Q: How do you create a commit in Git?
A: Use git commit -m “commit message” to save staged changes with a descriptive message.
Q: What does git clone do?
A: git clone <repository> copies a remote repository to your local machine.</repository>
Q: How do you view the commit history?
A: Use git log to display the commit history of the repository.
Q: What is a remote repository?
A: A remote repository is a version of your repository hosted on a server, such as GitHub, to enable collaboration.
Q: How do you link a remote repository to a local repository?
A: Use git remote add origin <repository> to connect to a remote repository.</repository>
Q: What command is used to push changes to a remote repository?
A: Use git push origin <branch> to upload local changes to the remote repository.</branch>
Q: What does git pull do?
A: git pull fetches changes from a remote repository and merges them into the current branch.
Q: What is the difference between git fetch and git pull?
A: git fetch downloads changes from a remote repository without merging, while git pull fetches and merges changes.
Q: How do you create a new branch in Git?
A: Use git branch <branch-name> to create a new branch.</branch-name>