Git Commands Flashcards: Everyday Workflow, Branching & Recovery
Practice essential Git commands with safe, current examples for staging, commits, branches, remotes, history, undoing changes, and recovery.
Về bộ thẻ này
Git commands are easier to remember when the prompt starts with a real situation: inspect a change, stage part of a file, move work onto a branch, update from a remote, or recover a commit that seemed lost.
What this deck practices
- Situation → command: choose a practical Git command or safe command sequence for the state in front of you.
- Command → effect: explain what a command reads or changes, including the working tree, index, branch, remote-tracking refs, or commit history.
- Risk → safer choice: distinguish local cleanup from shared-history changes, and recognize when
restore,revert,reset,reflog, or a force push needs extra care. - Output → next step: read common status, diff, log, bisect, stash, branch, tag, and worktree results well enough to continue.
The sequence starts with repository setup and observation, moves through staging and commits, then adds branches, remotes, integration, history, debugging, undo, and recovery. Related prompt directions are separated so the neighboring card doesn't give away the answer.
This deck covers 36 useful top-level commands with modern porcelain such as git switch and git restore. Common older git checkout and git reset <path> forms appear only as compatibility notes. It excludes hosting-service pull requests, GUIs, credentials, server administration, most low-level plumbing commands, hooks, signing, Git LFS, submodules, partial clones, custom aliases, and exhaustive option catalogs. The practical low-level exceptions are git ls-files, git merge-base, and git rev-parse, which support everyday inspection and comparison tasks.
CC0 applies to the independently authored questions, answers, organization, metadata, and generated cover only to the extent applicable rights exist; it doesn't license Git facts, documentation, names, or trademarks.
Facts and examples were checked against the current official Git documentation and executed in disposable repositories with Git 2.50.1. This is an independent, unofficial educational deck. It isn't affiliated with or endorsed by the Git Project or Software Freedom Conservancy. No documentation prose, logos, command tables, competitor cards, or assessment questions were copied.
Thẻ trong bộ này
Thẻ 1
Câu hỏi
Initialize the current directory as a Git repository.
Câu trả lời
git initcreates the repository metadata in the current directory.git initIt doesn't add or commit the existing files.
Thẻ 2
Câu hỏi
Set the commit email for only the current repository.
Câu trả lời
git config user.email dev@example.comsets a repository-local value.git config user.email dev@example.comOmitting
--globalkeeps other repositories unchanged.Thẻ 3
Câu hỏi
Open the full manual for
git status.Câu trả lời
git help statusopens the command's manual.git help statusUse
git status -hwhen you only need the short option summary in the terminal.Thẻ 4
Câu hỏi
Copy
../origin.gitinto a new local directory namedproject.Câu trả lời
git clone ../origin.git projectcreates the local clone inproject.git clone ../origin.git projectThe clone normally configures the source as the
originremote.Thẻ 5
Câu hỏi
Show tracked changes that haven't been staged.
Câu trả lời
git diffshows the working-tree changes relative to the index.git diffNew untracked files don't appear until Git knows about them.
Thẻ 6
Câu hỏi
Stage
notes.txtfor the next commit.Câu trả lời
git add notes.txtcopies the path's current content into the index.git add notes.txtLater edits to the file stay unstaged until you add them too.
Thẻ 7
Câu hỏi
Inspect which changes are staged, unstaged, or untracked.
Câu trả lời
git statuscompares the working tree and index withHEAD.git statusIt reads repository state; it doesn't modify files or history.
Thẻ 8
Câu hỏi
Record the staged snapshot with the message
Add notes.Câu trả lời
git commit -m "Add notes"creates a commit from the index.git commit -m "Add notes"Unstaged changes aren't included.
Thẻ 9
Câu hỏi
Delete the tracked file
obsolete.txtand stage that deletion.Câu trả lời
git rm obsolete.txtremoves the file and stages the removal.git rm obsolete.txtCommit afterward to record the deletion in history.
Thẻ 10
Câu hỏi
Rename tracked
old-name.txttonotes.txtand stage the change.Câu trả lời
git mv old-name.txt notes.txtmoves the path and updates the index.git mv old-name.txt notes.txtGit records snapshots, so it detects the rename from the resulting content when useful.
Thẻ 11
Câu hỏi
List local branches and show which one is current.
Câu trả lời
git branchlists local branches and marks the current one with*.git branchIt doesn't switch branches.
Thẻ 12
Câu hỏi
Switch the working tree to the existing branch
feature/login.Câu trả lời
git switch feature/loginswitches to that branch.git switch feature/loginGit updates the index and working tree, and refuses if the switch would overwrite local work. Older instructions often use
git checkoutfor branch switching;switchstates the intent more clearly.Thẻ 13
Câu hỏi
Show every configured remote with its fetch and push URL.
Câu trả lời
git remote -vlists remote names and URLs.git remote -vA remote name such as
originis a local shortcut, not a special server type.Thẻ 14
Câu hỏi
Read a compact one-line commit history.
Câu trả lời
git log --onelineprints one abbreviated entry per commit.git log --onelineThe newest reachable commit appears first.
Thẻ 15
Câu hỏi
Discard unstaged edits to tracked
notes.txt.Câu trả lời
git restore notes.txtreplaces the working-tree file with the indexed version.git restore notes.txtThis is destructive for those unstaged edits. Check
git diff -- notes.txtfirst when unsure.Thẻ 16
Câu hỏi
Clone
../origin.gitwhile naming the local directorysandbox.Câu trả lời
git clone ../origin.git sandboxseparates the source location from the local directory name.git clone ../origin.git sandboxRun it from the parent directory where
sandboxshould be created.Thẻ 17
Câu hỏi
Read the effective commit email in the current repository.
Câu trả lời
git config --get user.emailprints the selected configuration value.git config --get user.emailRepository-local configuration overrides a global value.
Thẻ 18
Câu hỏi
Get a compact status that still shows branch information.
Câu trả lời
git status --short --branchprints the branch line plus two-column path states.git status --short --branchThe left column describes the index; the right column describes the working tree.
Thẻ 19
Câu hỏi
Review what is staged for the next commit.
Câu trả lời
git diff --stagedcompares the index withHEAD.git diff --staged--cachedis the common equivalent spelling.Thẻ 20
Câu hỏi
Interactively stage selected hunks from
notes.txt.Câu trả lời
git add -p notes.txtlets you accept or reject each patch hunk.git add -p notes.txtThis is useful when one file contains changes for more than one commit.
Thẻ 21
Câu hỏi
Open the configured editor to write a commit message for the staged snapshot.
Câu trả lời
git commitopens the commit-message editor.git commitGit still commits only the staged content.
Thẻ 22
Câu hỏi
Stop tracking
local.envbut keep the file in the working tree.Câu trả lời
git rm --cached local.envstages removal from the index without deleting the local file.git rm --cached local.envAdd the path to an ignore rule if it shouldn't be staged again.
Thẻ 23
Câu hỏi
Create
feature/loginat the current commit without switching to it.Câu trả lời
git branch feature/logincreates the branch reference.git branch feature/loginUse
git switch -c feature/loginwhen you want to create and switch in one step.Thẻ 24
Câu hỏi
Add
../upstream.gitas a remote namedupstream.Câu trả lời
git remote add upstream ../upstream.gitstores that remote configuration.git remote add upstream ../upstream.gitIt doesn't fetch any refs until you run
git fetch upstream.Thẻ 25
Câu hỏi
View a compact decorated commit graph across all local refs.
Câu trả lời
git log --oneline --graph --decorate --allcombines history, topology, and ref names.git log --oneline --graph --decorate --allIt is a read-only way to understand how branches relate.
Thẻ 26
Câu hỏi
Inspect the current commit's metadata and patch.
Câu trả lời
git show HEADdisplays the commit and its changes.git show HEADReplace
HEADwith another revision when needed.Thẻ 27
Câu hỏi
Create
feature/searchat the current commit and switch to it.Câu trả lời
git switch -c feature/searchcreates and checks out the branch.git switch -c feature/searchNew commits now advance
feature/search.Thẻ 28
Câu hỏi
List the paths currently known to the index.
Câu trả lời
git ls-filesprints tracked and staged paths.git ls-filesIt is more precise than a filesystem listing when you need Git's view.
Thẻ 29
Câu hỏi
Refresh remote-tracking refs from
originwithout integrating them.Câu trả lời
git fetch origindownloads objects and updatesorigin/*refs.git fetch originYour current branch and working tree stay in place.
Thẻ 30
Câu hỏi
Unstage
notes.txtwhile keeping its working-tree edits.Câu trả lời
git restore --staged notes.txtrestores the index entry fromHEADby default.git restore --staged notes.txtThe file's edited content remains in the working tree.
Thẻ 31
Câu hỏi
Temporarily store tracked work with the label
WIP login.Câu trả lời
git stash push -m "WIP login"saves tracked staged and unstaged changes, then cleans them from the worktree.git stash push -m "WIP login"Untracked files stay put unless you add
-u.Thẻ 32
Câu hỏi
Check how the current branch differs from its configured upstream.
Câu trả lời
git status --branchreports ahead, behind, or diverged state when an upstream exists.git status --branchIt doesn't contact the remote, so fetch first when freshness matters.
Thẻ 33
Câu hỏi
Compare the snapshots at
mainandfeature/login.Câu trả lời
git diff main feature/loginshows changes needed to turn the first tree into the second.git diff main feature/loginThis compares the two named tips, not their merge base.
Thẻ 34
Câu hỏi
Stage all additions, modifications, and deletions in the current repository.
Câu trả lời
git add -Aupdates the index for every path in scope.git add -AReview
git diff --stagedbefore committing a broad change.Thẻ 35
Câu hỏi
Replace the current local commit with a corrected snapshot but keep its message.
Câu trả lời
git commit --amend --no-editcreates a replacement commit from the current index.git commit --amend --no-editAmending rewrites the commit ID. Avoid it after sharing the commit unless the team expects a history update.
Thẻ 36
Câu hỏi
Rename the current branch to
feature/auth.Câu trả lời
git branch -m feature/authrenames the checked-out branch.git branch -m feature/authIf the old name was already pushed, coordinate the remote rename separately.
Thẻ 37
Câu hỏi
Return to the branch you were on immediately before this one.
Câu trả lời
git switch -switches to the previously checked-out branch.git switch -It is handy for moving between two branches.
Thẻ 38
Câu hỏi
Integrate
feature/logininto the current branch.Câu trả lời
git merge feature/loginjoins the named branch into the current branch.git merge feature/loginThe result may be a fast-forward, merge commit, or conflict, depending on history and options.
Thẻ 39
Câu hỏi
Fetch only the
mainbranch fromorigin.Câu trả lời
git fetch origin maindownloads that branch and records the fetched tip inFETCH_HEAD.git fetch origin mainIt doesn't merge or move your current branch.
Thẻ 40
Câu hỏi
Update the current branch only when the remote change can fast-forward it.
Câu trả lời
git pull --ff-onlyfetches, then refuses to create a merge commit or rebase.git pull --ff-onlyA refusal leaves the divergent histories for you to inspect.
Thẻ 41
Câu hỏi
Push the current branch
feature/logintoorigin.Câu trả lời
git push origin feature/loginupdates the same-named remote branch.git push origin feature/loginIt doesn't configure an upstream unless your settings do that automatically.
Thẻ 42
Câu hỏi
Read commits that changed
notes.txt.Câu trả lời
git log -- notes.txtlimits history to commits affecting that path.git log -- notes.txtThe
--separates revisions and options from the path.Thẻ 43
Câu hỏi
Print
notes.txtexactly as it exists inHEADwithout switching commits.Câu trả lời
git show HEAD:notes.txtreads the blob at that revision and path.git show HEAD:notes.txtThis doesn't modify the working-tree file.
Thẻ 44
Câu hỏi
Search tracked working-tree files for the text
TODO, including unstaged edits.Câu trả lời
git grep TODOsearches tracked files in the working tree, including their unstaged content.git grep TODOIt skips untracked files by default.
Thẻ 45
Câu hỏi
Show the commit and author associated with each line of
notes.txt.Câu trả lời
git blame notes.txtannotates each line with its last recorded change.git blame notes.txtUse it as a history lead, not as proof that one person owns the current behavior.
Thẻ 46
Câu hỏi
Move the current branch back one commit while keeping the changes unstaged.
Câu trả lời
git reset HEAD~1performs the default mixed reset.git reset HEAD~1It rewrites the local branch tip but leaves the changed files in the working tree.
Thẻ 47
Câu hỏi
Stash tracked and untracked work together with the label
WIP search.Câu trả lời
git stash push -u -m "WIP search"includes untracked files.git stash push -u -m "WIP search"Ignored files still stay out unless you deliberately use the stronger
--alloption.Thẻ 48
Câu hỏi
List local tags whose names start with
v1..Câu trả lời
git tag --list "v1.*"filters the local tag names.git tag --list "v1.*"Listing tags doesn't contact a remote.
Thẻ 49
Câu hỏi
Resolve
HEADto its full object ID.Câu trả lời
git rev-parse HEADprints the object name selected by the revision.git rev-parse HEADThis is useful in scripts that need an exact commit ID.
Thẻ 50
Câu hỏi
Review prose edits as changed words instead of whole lines.
Câu trả lời
git diff --word-diffhighlights inline word-level changes.git diff --word-diffIt changes the display only; repository state stays untouched.
Thẻ 51
Câu hỏi
Integrate
feature/loginonly if the current branch can fast-forward.Câu trả lời
git merge --ff-only feature/loginrefuses histories that require a merge commit.git merge --ff-only feature/loginThe refusal is a safety check, not a partial merge.
Thẻ 52
Câu hỏi
Fetch
originand remove remote-tracking refs that the remote no longer has.Câu trả lời
git fetch --prune originrefreshes refs and prunes staleorigin/*names.git fetch --prune originIt doesn't delete local branches.
Thẻ 53
Câu hỏi
List commits reachable from
feature/loginbut not frommain.Câu trả lời
git log main..feature/login --onelineshows that one-sided revision range.git log main..feature/login --onelineThe order around
..matters.Thẻ 54
Câu hỏi
Replace working-tree
notes.txtwith its version fromHEAD~1.Câu trả lời
git restore --source=HEAD~1 notes.txtcopies the older blob into the working tree.git restore --source=HEAD~1 notes.txtThis overwrites current unstaged edits to
notes.txt. Diff, copy, or otherwise protect wanted edits first; then review and stage the restored version if you want to keep it.Thẻ 55
Câu hỏi
Create branch
hotfixin an additional working tree at../hotfix.Câu trả lời
git worktree add ../hotfix -b hotfixcreates the branch and checks it out there.git worktree add ../hotfix -b hotfixThe original working tree stays on its current branch.
Thẻ 56
Câu hỏi
Push
feature/loginand configureorigin/feature/loginas its upstream.Câu trả lời
git push -u origin feature/loginpushes the branch and records upstream tracking.git push -u origin feature/loginLater
git status,git pull, andgit pushcan use that relationship.Thẻ 57
Câu hỏi
Follow likely moved or copied lines while blaming
notes.txt.Câu trả lời
git blame -M -C notes.txtadds move and copy detection heuristics.git blame -M -C notes.txtThe result is still a clue for investigation, not an ownership verdict.
Thẻ 58
Câu hỏi
Replay the current branch's local commits on top of
main.Câu trả lời
git rebase mainrewrites those commits onto the new base.git rebase mainUse it on unshared work, or coordinate before rewriting commits other people may use.
Thẻ 59
Câu hỏi
Move the branch back one commit while keeping all reverted changes staged.
Câu trả lời
git reset --soft HEAD~1movesHEADbut leaves the index and working tree intact.git reset --soft HEAD~1This rewrites the local branch tip and is best kept to unshared history.
Thẻ 60
Câu hỏi
Create an annotated release tag
v1.0.0at the current commit.Câu trả lời
git tag -a v1.0.0 -m "Release 1.0.0"creates a tag object with a message.git tag -a v1.0.0 -m "Release 1.0.0"Tags aren't pushed automatically unless you push them explicitly.
Thẻ 61
Câu hỏi
Start a regression search with
HEADknown bad andHEAD~4known good.Câu trả lời
git bisect start, followed by bad and good boundaries, begins binary search through the range.git bisect start git bisect bad HEAD git bisect good HEAD~4Git checks out a midpoint for you to test.
Thẻ 62
Câu hỏi
Fetch the upstream branch, then replay local commits on top of it.
Câu trả lời
git pull --rebasecombines fetch with a rebase-based integration.git pull --rebaseIt rewrites local commits, so inspect the branch and keep shared-history expectations in mind.
Thẻ 63
Câu hỏi
Commit the staged update as
Update noteswhile leaving unstaged edits out.Câu trả lời
git commit -m "Update notes"records the index, not every working-tree edit.git commit -m "Update notes"Review both
git diff --stagedandgit diffwhen the split matters.Thẻ 64
Câu hỏi
Undo the current non-merge commit with a new commit instead of moving the branch backward.
Câu trả lời
git revert HEADapplies the inverse of the current non-merge commit and records it as a new commit.git revert HEADFor a merge commit, inspect its parents and use the mainline form taught later:
git revert -m <parent-number> <merge-commit>. Revert preserves shared history, which usually makes it safer than reset for published commits.Thẻ 65
Câu hỏi
Delete the fully merged local branch
feature/login.Câu trả lời
git branch -d feature/logindeletes the branch only when Git considers it merged.git branch -d feature/loginThe lowercase
-dguard helps prevent accidental loss of unmerged branch tips.Thẻ 66
Câu hỏi
Inspect
HEAD~1without moving any branch name.Câu trả lời
git switch --detach HEAD~1checks out the commit in detached-HEAD mode.git switch --detach HEAD~1Create a branch before leaving if you make commits you want to keep.
Thẻ 67
Câu hỏi
Find one best common ancestor of
mainandfeature/login.Câu trả lời
git merge-base main feature/loginprints one best merge base.git merge-base main feature/loginCriss-cross histories can have multiple equally best bases. Use
git merge-base --all main feature/loginwhen every best base matters; without--all, Git chooses one unspecified best base.Thẻ 68
Câu hỏi
Print the top-level directory of the current working tree.
Câu trả lời
git rev-parse --show-toplevelresolves the repository root path.git rev-parse --show-toplevelIt fails outside a working tree, which is useful in scripts that require one.
Thẻ 69
Câu hỏi
Inspect recent local movements of
HEAD.Câu trả lời
git reflog --onelineshows the local reference-update history in compact form.git reflog --onelineIt can reveal commits hidden by reset or rebase while their objects still exist.
Thẻ 70
Câu hỏi
List stashes, then summarize the newest stash's changed paths.
Câu trả lời
git stash listnames the entries, andgit stash show --stat stash@{0}summarizes the newest one.git stash list git stash show --stat stash@{0}Neither command removes or applies the stash.
Thẻ 71
Câu hỏi
Apply the tip commit from
feature/loginwithout conflicts and record where it came from.Câu trả lời
git cherry-pick -x feature/loginapplies the commit and, when it applies without conflicts, adds a source-commit line to the message.git cherry-pick -x feature/loginUse
-xwhen the trace is useful and the picked commit is public enough to name.Thẻ 72
Câu hỏi
Preview which untracked files under
scratch/Git would delete.Câu trả lời
git clean -nd -- scratch/performs a scoped dry run.git clean -nd -- scratch/Run the preview before replacing
-nwith-f; ignored files aren't included here.Thẻ 73
Câu hỏi
Identify conflicted paths after a merge stops.
Câu trả lời
git status --shortmarks unmerged paths with combinations such asUU.git status --shortResolve each path, stage the result, then complete the merge commit—or abort the merge.
Thẻ 74
Câu hỏi
Continue a rebase after resolving and staging its conflicts.
Câu trả lời
git rebase --continuerecords the resolved step and moves to the next commit.git rebase --continueIf the resolution is wrong or the rewrite is no longer wanted, abort instead.
Thẻ 75
Câu hỏi
List every working tree attached to the repository.
Câu trả lời
git worktree listshows each path, checked-out commit, and branch when attached.git worktree listA branch normally can't be checked out in two worktrees at once.
Thẻ 76
Câu hỏi
Fetch and integrate the upstream with merge semantics rather than rebase.
Câu trả lời
git pull --no-rebasefetches, then merges the selected upstream.git pull --no-rebaseUse an explicit policy so the integration behavior isn't a surprise.
Thẻ 77
Câu hỏi
Interactively discard selected unstaged hunks from
notes.txt.Câu trả lời
git restore -p notes.txtasks which working-tree hunks to restore from the index.git restore -p notes.txtAccepted hunks are discarded, so review each prompt carefully.
Thẻ 78
Câu hỏi
Delete the remote branch
feature/loginfromorigin.Câu trả lời
git push origin --delete feature/loginremoves that remote ref.git push origin --delete feature/loginIt doesn't delete anyone's local branch or existing commits immediately.
Thẻ 79
Câu hỏi
Mark
HEAD~4as a known good boundary during a bisect session.Câu trả lời
git bisect good HEAD~4tells Git that the named commit doesn't contain the bug.git bisect good HEAD~4Git uses good and bad boundaries to choose the next midpoint.
Thẻ 80
Câu hỏi
Delete the local tag
v1.0.0.Câu trả lời
git tag -d v1.0.0removes the local tag reference.git tag -d v1.0.0A remote copy, if any, needs a separate remote update.
Thẻ 81
Câu hỏi
Move the branch back one commit and discard the index and working-tree changes.
Câu trả lời
git reset --hard HEAD~1makes the branch, index, and tracked working tree matchHEAD~1.git reset --hard HEAD~1This is destructive. It can also delete or overwrite untracked files or directories that obstruct paths tracked by the target commit. Confirm the target and move wanted work first.
Thẻ 82
Câu hỏi
Give the current commit a human-readable name based on reachable tags.
Câu trả lời
git describe --tags --alwaysuses the nearest tag when possible and falls back to an object name.git describe --tags --alwaysIt reads history without creating or moving a tag.
Thẻ 83
Câu hỏi
Continue a cherry-pick after resolving and staging its conflicts.
Câu trả lời
git cherry-pick --continuefinishes the current picked commit.git cherry-pick --continueGit may continue to another commit if the original request included a sequence.
Thẻ 84
Câu hỏi
Delete ordinary, non-ignored untracked files and directories only under
scratch/.Câu trả lời
git clean -fd -- scratch/removes ordinary, non-ignored untracked files and directories under that path.git clean -fd -- scratch/It leaves ignored content and nested Git repositories in place. This can't be recovered through normal Git history, so run the matching dry run first.
Thẻ 85
Câu hỏi
Apply the inverse of the current non-merge commit to the index and working tree without committing yet.
Câu trả lời
git revert --no-commit HEADprepares the inverse of the current non-merge commit for inspection.git revert --no-commit HEADFor a merge commit, inspect its parents and use the mainline form taught later:
git revert -m <parent-number> <merge-commit>. You can combine or edit the prepared change before creating a commit.Thẻ 86
Câu hỏi
Apply the newest stash while keeping it in the stash list.
Câu trả lời
git stash apply stash@{0}reapplies the entry without dropping it.git stash apply stash@{0}Use
poponly when you want a successful apply to remove the entry automatically.Thẻ 87
Câu hỏi
Create branch
recoveredat the previous recorded location ofHEAD.Câu trả lời
git branch recovered HEAD@{1}gives the reflog entry a durable branch name.git branch recovered HEAD@{1}Inspect the entry first; reflog positions change as new reference updates happen.
Thẻ 88
Câu hỏi
Abandon the current conflicted merge and return to its pre-merge state.
Câu trả lời
git merge --abortstops the in-progress merge.git merge --abortUncommitted changes that predated the merge can make exact reconstruction harder, so start risky merges from a clear state.
Thẻ 89
Câu hỏi
Unstage
notes.txtwith the older path-specific reset form.Câu trả lời
git reset HEAD -- notes.txtresets only the index entry and keeps working-tree edits.git reset HEAD -- notes.txtModern instructions usually prefer
git restore --staged notes.txtfor this job.Thẻ 90
Câu hỏi
Remove the clean linked working tree at
../hotfix.Câu trả lời
git worktree remove ../hotfixremoves that working tree and its administrative record.git worktree remove ../hotfixIt refuses a dirty working tree unless you force it; inspect and save work instead of forcing by habit.
Thẻ 91
Câu hỏi
Force-update
feature/loginonly if its remote tip matches your localorigin/feature/loginexpectation.Câu trả lời
git push --force-with-lease origin feature/logincompares the remote branch with the local remote-tracking ref before force-updating.git push --force-with-lease origin feature/loginBackground or automatic fetches can move that local ref and weaken the check. Inspect the fetched tip, coordinate the rewrite, and use an explicit
<ref>:<expect>lease when exact protection matters.Thẻ 92
Câu hỏi
Abandon the current rebase and restore the branch to its pre-rebase state.
Câu trả lời
git rebase --abortstops the rewrite and restores the original branch tip.git rebase --abortUse it when the conflict resolution or rewrite plan isn't worth continuing.
Thẻ 93
Câu hỏi
Revert the current merge commit while keeping its first parent as the mainline.
Câu trả lời
git revert -m 1 HEADcreates an inverse change relative to parent 1.git revert -m 1 HEADChoosing the wrong mainline changes the meaning, so inspect the merge's parents first. Its ancestors remain integrated in history, which means a later merge may not restore the reverted tree changes automatically.
Thẻ 94
Câu hỏi
End a bisect session and return to the branch or commit checked out before it.
Câu trả lời
git bisect resetrestores the pre-bisect checkout.git bisect resetRun it after identifying the first bad commit or when abandoning the search.
Thẻ 95
Câu hỏi
Read the reflog specifically for
HEAD.Câu trả lời
git reflog show HEADdisplays local movements recorded forHEAD.git reflog show HEADReflogs are local recovery records; they aren't a shared remote audit log.
Thẻ 96
Câu hỏi
Abandon the current conflicted cherry-pick.
Câu trả lời
git cherry-pick --abortrestores the state from before the cherry-pick sequence.git cherry-pick --abortUse it instead of stacking unrelated cleanup commands onto a failed pick.
Thẻ 97
Câu hỏi
Interactively edit the last three local commits before sharing them.
Câu trả lời
git rebase -i HEAD~3opens a plan for reordering, editing, squashing, or dropping those commits.git rebase -i HEAD~3Every changed commit gets a new ID. Keep interactive rebase to unshared work unless everyone has coordinated.
Thẻ 98
Câu hỏi
Run
./test.shautomatically at each midpoint of an active bisect.Câu trả lời
git bisect run ./test.shclassifies commits from the script's exit status.git bisect run ./test.shThe test must be deterministic: exit 0 for good, 1–127 except 125 for bad, and 125 to skip an untestable commit.
98 thẻ
Git Commands Flashcards: Everyday Workflow, Branching & Recovery
Nibomo sẽ mở ra để bạn bắt đầu học.