Git Essentials
100 flashcards by MentisLibrary
The commands and concepts you need day to day, from staging and branching to rebase, stash and undoing mistakes, plus how Git stores objects and refs, tags and remotes, submodules and LFS, and the branching workflows teams settle on.
- What is Git?
- A distributed version control system that tracks changes to files over time
- Which command creates a new Git repository?
- git init
- Which command copies a remote repository to your machine?
- git clone <url>
- Which command shows the state of the working directory and staging area?
- git status
- Which command stages changes for the next commit?
- git add <path>
- Which command records staged changes into history?
- git commit
- What is the staging area (index)?
- A buffer between the working directory and history where you assemble the next commit
- Which command shows commit history?
- git log
- Which command shows unstaged changes?
- git diff
- What is a branch in Git?
- A movable pointer to a commit, giving you an independent line of development
- Which command creates and switches to a new branch in one step?
- git switch -c <name> (or git checkout -b <name>)
- Which command merges another branch into the current one?
- git merge <branch>
- What is a fast-forward merge?
- A merge where the branch pointer simply moves forward because no divergent commits exist
- What is a merge conflict?
- A situation where Git cannot auto-combine changes because both branches edited the same lines
- What does git rebase do?
- Replays your commits on top of another base commit, producing a linear history
- What is the difference between merge and rebase?
- Merge preserves history shape with a merge commit; rebase rewrites commits into a straight line
- What does git rebase -i (interactive rebase) let you do?
- Reorder, squash, edit, reword, or drop commits before sharing them
- What does git stash do?
- Temporarily shelves uncommitted changes so you get a clean working directory
- Which command lists your stashes?
- git stash list
- What does git pull do?
- Fetches from the remote and merges (or rebases) the changes into your current branch
- What does git fetch do?
- Downloads remote commits and updates remote-tracking branches without touching your work
- What does git push do?
- Uploads your local commits to a remote repository
- What is origin in Git?
- The default name for the remote repository you cloned from
- What is HEAD in Git?
- A pointer to the commit you currently have checked out, usually via a branch
- What is a detached HEAD state?
- HEAD pointing directly at a commit instead of a branch
- What is the difference between git reset --soft, --mixed, and --hard?
- --soft keeps changes staged; --mixed (default) keeps them unstaged; --hard discards them entirely
- What does git revert do?
- Creates a new commit that undoes the changes of an earlier commit
- What does git cherry-pick do?
- Applies the changes of a specific commit from elsewhere onto the current branch
- What does git reflog show?
- A log of everywhere HEAD has pointed, including commits no branch references anymore
- What is a tag in Git?
- A named pointer to a specific commit, typically marking a release