Git Workflow Flashcards
Q: What is the typical sequence of steps in a basic Git workflow?
A: Modify files → Stage changes (git add) → Commit changes (git commit) → Push to a remote (git push).
Q: How do you initialise a new Git repository?
A: Use git init in the project directory.
Q: How do you clone an existing remote repository?
A: Use git clone <repository>.</repository>
Q: How do you check the status of your working directory?
A: Use git status.
Q: What is the difference between staged and unstaged changes?
A: Staged changes are added to the index (staging area) and ready to commit, while unstaged changes are modified files not yet added.
Q: How do you stage changes for a specific file?
A: Use git add <file>.</file>
Q: How do you stage all changes in your working directory?
A: Use git add . or git add –all.
Q: How do you commit staged changes with a message?
A: Use git commit -m “commit message”.
Q: How do you include all changes (staged and unstaged) in a commit without staging them first?
A: Use git commit -a -m “commit message”.
Q: How do you push your changes to a remote repository?
A: Use git push origin <branch>.</branch>
Q: How do you pull changes from a remote repository?
A: Use git pull.
Q: How do you fetch changes from a remote repository without merging them?
A: Use git fetch.
Q: What is the purpose of branching in Git?
A: Branching allows you to work on different features or fixes independently without affecting the main codebase.
Q: How do you create a new branch?
A: Use git branch <branch-name>.</branch-name>
Q: How do you switch to a different branch?
A: Use git checkout <branch-name> or git switch <branch-name>.</branch-name></branch-name>