Challenge your basic knowledge of Git version control concepts, commands, and workflows with easy questions. Perfect for beginners aiming to grasp core Git terminology and practical usage in collaborative coding projects.
Which Git command is used to create a new, empty repository in the current directory?
Explanation: The correct answer is 'git init' because this command initializes a new Git repository in the current directory, making it ready for version control. 'git start', 'git begin', and 'git create' are not valid Git commands for this purpose; while they sound plausible, they do not exist in the standard Git command set. Only 'git init' achieves the desired result of creating a new repository.
If you want to make a local copy of a remote Git repository, which command should you use?
Explanation: 'git clone' copies a remote repository and sets it up locally, making it the correct choice for this task. 'git copy' may sound similar but is not a Git command. 'git fetch' only updates your information from the remote but does not create a new copy. 'git pull' updates your existing local repository with changes from the remote, not creating a new one.
Which command do you use to move changes from your working directory to the staging area before committing?
Explanation: 'git add' is the correct command to stage changes before a commit. 'git stage', though it sounds related, is not a valid command in standard Git. 'git insert' and 'git place' are not actual Git commands and do not affect file staging. Only 'git add' prepares files for the next snapshot.
After staging changes, which Git command is used to save those changes as a new commit in the repository?
Explanation: 'git commit' officially records staged changes to the repository history. Although 'git save', 'git record', and 'git submit' seem relevant, none correspond to real Git commands for this action. You must use 'git commit' to permanently add changes to the project's history.
What command allows you to see a list of previous commits in your repository?
Explanation: 'git log' is the correct command to view a history of commits. 'git list' is not used for commits in Git, though it might sound correct. 'git history' and 'git track' are also not valid Git commands for showing commit history. Only 'git log' displays this information.
If you want to switch from your current branch to a different branch called 'feature', what command would you use?
Explanation: 'git checkout feature' is the correct command for moving from one branch to another in many Git versions. 'git switch feature' is valid only in newer versions, but for basic knowledge, 'git checkout' is standard. 'git jump feature' and 'git change feature' are incorrect as they are not recognized Git commands.
What is the primary purpose of a file named .gitignore in a Git repository?
Explanation: A .gitignore file tells Git which files or directories to exclude from tracking, helping you avoid committing unwanted files. It does not delete files or lock them for editing; those are misunderstandings. 'To display hidden files' also misrepresents its function, which is for ignoring, not displaying.
Which command would you use to undo all local changes in your working directory that have not been staged?
Explanation: 'git checkout -- .' discards all unstaged changes in your working directory, restoring the last committed state. 'git revert' creates a new commit that undoes changes rather than changing the working directory directly. 'git commit --amend' modifies the previous commit rather than unstaged changes. 'git transfer' is not a Git command.
Which command is used to upload your local commits to a remote repository?
Explanation: 'git push' uploads local commits to a remote repository, sharing your changes. 'git deploy' is unrelated to version control and is not a Git command. 'git forward' and 'git send' sound reasonable, but they do not exist in Git for this operation. Only 'git push' synchronizes local and remote repositories in this way.
What is the most common name used for the default initial branch in a new Git repository?
Explanation: 'main' is the typical default branch name in modern Git repositories, used as the standard starting point. 'start', 'base', and 'primary' may sound suitable, but they are not defaults in Git. Although 'master' was historically standard, 'main' has become preferred for new repositories.