Setup and configuration 9
The older option forms of git config (a bare name to read, name and value to write, --list) are deprecated; the manual recommends the get, set and list subcommands shown here.
| Command | What it does |
|---|---|
git config --global user.name "Your Name Comes Here" | Set your author nameRun it once before the first commit; the name goes into the author field of every commit you make. |
git config --global user.email [email protected] | Set your author emailWith --global the value goes into your per-user configuration file, not into this repository. |
git config list | List all settingsPrints every variable found in the system, per-user and repository files together with its value. |
git config get NAME | Read one settingPrints the last value stored for the variable and returns exit code 1 when it is not set. |
git config set NAME VALUE | Change a settingWrites to the repository's own config by default; add --global to store it for your user account. |
git help | List common commandsWith no arguments it prints the synopsis and the most commonly used commands. |
git help COMMAND | Open a command manual pageBrings up the manual page of that command, by default with the man program. |
git version | Show the installed versionPrints the Git version number; --build-options adds details of how it was built. |
git --version | Show version (option form)Converted internally into git version, so both print the same thing. |
Starting a repository 6
| Command | What it does |
|---|---|
git init | Create a repository hereAdds a .git directory to the current folder and overwrites nothing when one is already there. |
git init -b BRANCH-NAME | Choose the first branch nameOverrides the default initial branch name, which the manual gives as master until Git 3.0 switches to main. |
git clone REPOSITORY | Clone a repositoryCreates a new directory, a remote-tracking branch for every remote branch, and checks out the initial branch. |
git clone --depth DEPTH REPOSITORY | Make a shallow cloneTruncates history to the given number of commits and implies --single-branch. |
git clone -b NAME REPOSITORY | Clone and check out a branchChecks out the named branch, not the remote default; a tag name gives a detached HEAD. |
git clone --recurse-submodules | Clone with submodulesInitialises and clones every submodule once the main clone is finished. |
Staging and committing 17
| Command | What it does |
|---|---|
git status | Show working tree statusLists staged changes, unstaged changes and untracked files. |
git status -s | Show status in short formatPrints one line per path with a two-letter status code. |
git add PATHSPEC | Stage filesAdds the current content of the matching files to the index, ready for the next commit. |
git add . | Stage the current directoryStages everything under the directory you are in, new files included. |
git add -A | Stage all changesAlso records deletions; without a pathspec it covers the entire working tree. |
git add -u | Stage tracked files onlyStages modifications and deletions of files Git already tracks and adds no new files. |
git add -p | Stage selected hunksWalks through the changes hunk by hunk so that only part of a file is staged. |
git commit | Commit staged changesOpens your editor for the message when none is supplied on the command line. |
git commit -m MSG | Commit with a messageTakes the message from the command line; repeating -m adds further paragraphs. |
git commit -a | Commit all tracked changesStages modified and deleted tracked files first; files never added stay out. |
git commit --amend | Replace the last commitCreates a new commit in place of the branch tip, reusing its message unless you change it. |
git commit --amend --no-edit | Amend without editing messageAdds the staged changes to the last commit and keeps its message as it is. |
git rm PATHSPEC | Delete tracked filesDeletes the files on disk and stages their removal for the next commit. |
git rm --cached PATHSPEC | Stop tracking a fileRemoves the path from the index only; the file itself stays on disk. |
git mv SOURCE DESTINATION | Rename or move a fileRenames the file, directory or symlink and updates the index in the same step. |
git gui | Open the graphical interfaceTcl/Tk tool for making and amending commits, creating branches, merging and pushing. |
git citool | Open the commit dialogGraphical one-shot commit: review changes, stage them, type a message and record the commit. |
Comparing changes 9
| Command | What it does |
|---|---|
git diff | Show unstaged changesShows edits not yet staged: the working tree against the index. |
git diff --cached | Show staged changesCompares the index with the last commit: what is staged for the next one. |
git diff --staged | Show staged changes (synonym)Does exactly what --cached does; both names are accepted. |
git diff HEAD | Show all uncommitted changesCompares the working tree with the last commit, so staged and unstaged edits show together. |
git diff topic master | Compare two branchesShows the differences between the tips of the two branches. |
git diff topic...master | Diff since the branch pointThree dots show what changed on master after topic was started from it. |
git diff --stat | Summarise changes per filePrints a diffstat, a per-file summary of how much changed, in place of the patch text. |
git difftool | Open changes in a diff toolTakes the same arguments as git diff and opens each changed file in an external tool. |
git range-diff RANGE1 RANGE2 | Compare two commit rangesShows how two versions of a patch series differ, for example a branch before and after a rebase. |
Branching and merging 21
| Command | What it does |
|---|---|
git branch | List local branchesWith no arguments it lists local branches and marks the current one with an asterisk. |
git branch BRANCH-NAME | Create a branchPoints the new branch at the current HEAD but leaves you on the branch you were on. |
git branch -d BRANCH-NAME | Delete a merged branchRefuses unless the branch is fully merged into its upstream, or into HEAD when it has none. |
git branch -D BRANCH-NAME | Force-delete a branchShortcut for --delete --force: removes the branch whatever its merge status. |
git branch -m OLD-BRANCH NEW-BRANCH | Rename a branchRenames the branch together with its configuration and reflog. |
git branch -a | List local and remote branchesAdds the remote-tracking branches to the usual list of local ones. |
git branch --merged | List merged branchesLists only branches whose tips are reachable from HEAD, or from a commit you name. |
git branch --show-current | Print the current branchPrints the branch name alone, or nothing in detached HEAD state. |
git switch BRANCH | Switch to a branchMakes the working tree and index match that branch; later commits are added to it. |
git switch -c NEW-BRANCH | Create and switch to a branchCreates the branch at the current commit, or at a start point you add, and switches to it. |
git switch - | Switch to the previous branchReturns to the branch you were on before the last switch. |
git checkout BRANCH | Switch branches with checkoutOne command with two modes, switching branches and restoring files; git switch covers the first. |
git checkout -b NEW-BRANCH | Create and check out a branchStarts the branch at the current commit unless a start point follows, then checks it out. |
git merge COMMIT | Merge into the current branchBrings the history of the named branch or commit into the current branch, with a merge commit when needed. |
git merge --no-ff | Always create a merge commitRecords a merge commit even when the branch could simply be fast-forwarded. |
git merge --squash | Squash a branch into one changeApplies the combined changes to the working tree and index without committing or recording a merge. |
git merge --abort | Cancel a conflicted mergeStops the merge and tries to put the working tree back as it was before. |
git merge --continue | Finish a mergeConcludes the merge once every conflict has been resolved and staged. |
git mergetool | Resolve conflicts in a toolOpens each conflicted file in a merge utility; typically run after a merge stops on conflicts. |
git merge-tree BRANCH1 BRANCH2 | Merge without touching filesPerforms the merge without reading or writing the working tree or index and makes no commit. |
git rerere | Reuse recorded resolutionsReplays how you resolved a conflict when the same one returns; needs rerere.enabled set. |
Remotes and syncing 19
A plain git pull only fast-forwards. When your branch and the remote branch have diverged it fails until you pick --rebase or --no-rebase, or set pull.rebase or pull.ff.
| Command | What it does |
|---|---|
git remote | List remotesWith no arguments it prints the names of the existing remotes. |
git remote -v | List remotes with URLsShows the URL after each remote name. |
git remote add NAME URL | Add a remoteRegisters the repository under that name so git fetch can update its remote-tracking branches. |
git remote remove NAME | Remove a remoteDeletes the remote together with its remote-tracking branches and settings. |
git remote set-url NAME NEWURL | Change a remote URLReplaces the URL stored for the remote; --push changes the push URL only. |
git fetch | Download from a remoteUpdates the remote-tracking branches; the remote defaults to origin or to the upstream of the current branch. |
git fetch --all | Fetch from all remotesFetches from every configured remote in one run. |
git fetch --prune | Fetch and prune stale branchesAlso removes remote-tracking references that no longer exist on the remote. |
git pull | Fetch and integrateRuns git fetch, then integrates the upstream branch into the current one; by default only as a fast-forward. |
git pull --rebase | Pull with rebaseRebases your local commits on top of the fetched branch in place of a merge. |
git pull --ff-only | Pull by fast-forward onlyThe default mode: updates by fast-forward and stops with an error if the two branches have diverged. |
git pull --no-rebase | Pull with a mergeMerges the fetched branch into yours, which records a merge commit when the two have diverged. |
git push | Upload commits to a remoteWith no arguments it normally pushes the current branch to its upstream branch of the same name. |
git push origin main | Push a branch to a remoteUpdates main on the remote called origin from your local main. |
git push --set-upstream REMOTE BRANCH | Push and set upstreamShort form -u; records the remote branch as the upstream that a bare git pull then uses. |
git push --force-with-lease | Force push safelyOverwrites the remote branch only if it still points where your remote-tracking ref says it does. |
git push --force | Force pushDisables the ancestry check, so commits on the remote that you do not have are lost. |
git push --tags | Push all tagsSends every local tag along with the refs you name. |
git push origin :experimental | Delete a remote branchAn empty source before the colon deletes the matching branch on origin. |
Inspecting history 28
| Command | What it does |
|---|---|
git log | Show commit historyLists the commits reachable from HEAD, newest first, with author, date and message. |
git log --oneline | Show one line per commitShorthand for --pretty=oneline --abbrev-commit: an abbreviated hash and the subject. |
git log --graph | Draw the branch graphDraws the branch and merge structure as a text graph beside the commits. |
git log -p | Show patches in the logPrints the diff each commit introduces below its log message. |
git log --follow builtin/rev-list.c | Follow a file across renamesHistory of one file, continued past the point where it got its present name. |
git log -S'foo()' | Find commits changing a stringLists commits whose diff changes how many times the string occurs (the pickaxe search). |
git log --since="2 weeks ago" -- gitk | Limit log by date and pathOnly commits from the past fortnight that touch the file named after the two dashes. |
git log -3 | Limit the number of commitsStops after the three most recent commits; any number works. |
git log master..test | List commits on one branch onlyLists the commits that test has and master does not. |
git show | Show a commitDefaults to HEAD: prints the log message and the textual diff of that commit. |
git show next~10:Documentation/README | Print a file from a commitREV:PATH names a file as it was in that commit; here ten commits before the tip of next. |
git blame FILE | Show who changed each lineAnnotates every line with the commit and author that last modified it. |
git blame -L 40,60 foo | Blame a line rangeRestricts the annotation to lines 40 to 60 of the file foo. |
git annotate FILE | Annotate file linesSame data as git blame in a slightly different output format; kept for older scripts. |
git shortlog | Summarise commits by authorGroups commit titles under each author, the layout used in release announcements. |
git shortlog -s -n | Rank authors by commit countPrints only a count per author, sorted from most to fewest. |
git describe | Name a commit after a tagPrints the nearest reachable tag, plus a commit count and abbreviated hash when the commit itself is untagged. |
git reflog | Show where HEAD has beenLists recent updates to HEAD, including branch switches; name a ref to see its log. |
git grep PATTERN | Search tracked filesLooks for the pattern in the tracked files of the working tree and prints each hit. |
git grep -n | Search with line numbersPrefixes every match with its line number. |
git bisect start | Start a bisect sessionBegins a binary search for the commit that introduced a bug; mark one bad and one good commit next. |
git bisect bad | Mark a commit as badSays the version you just tested is broken; Git then checks out the next commit to test. |
git bisect good | Mark a commit as goodSays the version you just tested works correctly. |
git bisect reset | End a bisect sessionCleans up and returns to the commit that was checked out before the search started. |
git show-branch | Compare branch historiesDraws the commit ancestry of several branches side by side, 26 branches and commits at most. |
git whatchanged | Show logs with raw diffsLike git log with raw diff output and merges skipped; kept for historical reasons. |
gitk | Open the history browserGraphical viewer for the commit graph, each commit's details and the files it changed. |
git instaweb | Browse the repository in gitwebSets up gitweb and a web server so the local repository can be browsed in a browser. |
Undoing changes 16
Three similarly named commands do different jobs: git reset moves the branch tip, git restore only changes files in the working tree or index, and git revert adds a new commit that reverses an earlier one.
| Command | What it does |
|---|---|
git restore PATHSPEC | Discard working tree changesOverwrites the files with their staged version, so unstaged edits to them are lost. |
git restore . | Discard changes in this directoryApplies the restore to every file under the directory you are in. |
git restore --staged PATHSPEC | Unstage filesResets the index entries to HEAD; the edits stay in the working tree. |
git restore --source master~2 Makefile | Restore a file from a commitTakes the file from another commit, here two commits before the tip of master. |
git reset | Unstage everythingDefaults to --mixed and HEAD: the index is reset while files in the working tree stay as they are. |
git reset HEAD^ | Undo the last commit, keep editsMoves the branch back one commit and unstages its changes; the files keep their content. |
git reset --soft HEAD^ | Undo the last commit, keep it stagedMoves the branch back one commit and leaves the index and working tree untouched. |
git reset --hard | Discard all uncommitted changesResets the index and overwrites tracked files to match HEAD, so local changes are lost. |
git reset --hard HEAD^ | Delete the last commitDrops the newest commit from the branch together with every uncommitted change. |
git reset --hard HEAD~3 | Delete the last three commitsRewinds the branch and discards those changes; not for commits already given to others. |
git reset --hard ORIG_HEAD | Undo a merge or pullReturns the branch to where it was before the operation and throws away local changes. |
git revert COMMIT | Reverse a commitAdds a new commit that undoes the named one, leaving existing history as it is. |
git revert HEAD~3 | Revert an older commitUndoes the fourth-newest commit of the branch in one new commit. |
git clean -f | Delete untracked filesRemoves untracked files from the current directory down; -f is required unless clean.requireForce is false. |
git clean -n | Preview what clean would deleteDry run: lists the untracked files without removing anything. |
git clean -d | Include untracked directoriesLets clean go into untracked directories, which it otherwise leaves alone. |
Stashing 9
Stash entries are named with reflog syntax: stash@{0} is the newest, stash@{1} the one before it, and a bare number N means stash@{N}.
| Command | What it does |
|---|---|
git stash | Stash uncommitted changesSaves staged and unstaged changes to tracked files and resets the working tree to HEAD. |
git stash push -m MESSAGE | Stash with a descriptionSaves the changes together with your own description of the stashed state. |
git stash -u | Stash untracked files tooIncludes untracked files in the entry and then removes them from the working tree. |
git stash list | List stash entriesShows every entry, newest first as stash@{0}. |
git stash show -p stash@{1} | Show a stash as a patchPrints the full diff of the second-newest entry. |
git stash pop | Restore and drop the latest stashApplies the newest entry and removes it from the list, unless the apply ends in conflicts. |
git stash apply | Restore a stash and keep itWorks like pop but leaves the entry in the stash list. |
git stash drop | Delete a stash entryRemoves the latest entry, or the one you name, without applying it. |
git stash clear | Delete all stash entriesRemoves every entry at once; the manual warns they may be impossible to recover. |
Tags and notes 8
| Command | What it does |
|---|---|
git tag | List tagsPrints all tag names; add -l with a pattern to filter them. |
git tag TAGNAME | Create a lightweight tagWithout -a, -s or -u it only creates a name pointing at HEAD or at a commit you add. |
git tag -a TAGNAME | Create an annotated tagMakes a full tag object with tagger, date and message; an editor opens unless -m is given. |
git tag -d TAGNAME | Delete a tagDeletes the named local tags; several names can be given at once. |
git tag -l PATTERN | List tags matching a patternTreats the pattern as a shell wildcard and prints only the matching tag names. |
git verify-tag TAG | Check tag signaturesValidates the signature that git tag put on each tag object listed. |
git verify-commit COMMIT | Check commit signaturesValidates the signature that git commit -S put on the commits you name. |
git notes | List commit notesNotes attach extra text to a commit without changing the commit itself. |
Rebasing and cherry-picking 14
| Command | What it does |
|---|---|
git rebase | Rebase onto the upstream branchWith no arguments it replays your commits on the configured upstream of the current branch. |
git rebase master | Rebase onto another branchReapplies the commits of the checked-out branch on top of the tip of master. |
git rebase -i HEAD~5 | Edit the last five commitsOpens the todo list for those commits so you can reorder, squash, reword or drop them. |
git rebase --onto master next topic | Move a branch to a new baseReplays the commits of topic that are not in next onto master. |
git rebase --continue | Continue after conflictsResumes the rebase once the conflicted files are fixed and marked resolved with git add. |
git rebase --abort | Cancel a rebaseEnds the operation and puts the branch back where it was before the rebase. |
git rebase --autosquash | Fold fixup commits while rebasingMoves commits whose message starts with fixup! or squash! next to their target and combines them. |
git commit --fixup COMMIT | Commit a fix for an earlier commitMakes a fixup! commit that a later rebase with --autosquash folds into the named commit. |
git cherry-pick COMMIT | Copy a commit onto this branchApplies the change that commit introduced and records it as a new commit here. |
git cherry-pick --continue | Continue a cherry-pickCarries on with the sequence after the conflicts have been resolved. |
git cherry-pick --abort | Cancel a cherry-pickGives up on the sequence and restores the state from before it started. |
git history reword COMMIT | Reword an older commitExperimental command: opens an editor on that commit's message and changes nothing else in it. |
git filter-branch | Rewrite history with filtersRewrites whole branches through custom filters; the manual warns of pitfalls and recommends git filter-repo. |
git replace OBJECT REPLACEMENT | Substitute one object for anotherCreates a ref under refs/replace/ so that Git reads the replacement wherever the original is used. |
Worktrees, submodules and sparse checkout 10
| Command | What it does |
|---|---|
git worktree add PATH | Add a working treeCreates a second checkout at that path on a new branch named after the last path component. |
git worktree list | List working treesShows each working tree with its path, checked-out commit and branch; the main one comes first. |
git worktree remove WORKTREE | Remove a working treeWorks only on a clean linked working tree unless -f is added; the main one cannot be removed. |
git submodule | Show submodule statusCalled without a subcommand it reports the state of each submodule. |
git submodule add REPOSITORY PATH | Add a submoduleClones the repository at that path and stages the new submodule for the next commit of the superproject. |
git submodule update | Check out submodule commitsClones missing submodules and checks out the commit the superproject records for each. |
git submodule update --init --recursive | Fetch all nested submodulesInitialises and updates every submodule, including those inside other submodules. |
git sparse-checkout set MY/DIR1 SUB/DIR2 | Limit checkout to directoriesKeeps the files under the listed directories, plus those directly in their parent folders and at top level. |
git sparse-checkout disable | Turn sparse checkout offBrings every tracked file back into the working directory. |
git backfill | Download missing blobsIn a blobless partial clone, fetches the missing file contents in batches ahead of time. |
Patches and email 8
| Command | What it does |
|---|---|
git format-patch origin | Export commits as patch filesWrites one mail-formatted file per commit that is on your branch but not on origin. |
git am | Apply patches from a mailboxReads mbox files, or standard input, and turns each message into a commit. |
git am --continue | Continue applying patchesCarries on after a failed patch has been fixed up by hand and staged. |
git apply PATCH | Apply a patch fileChanges working tree files only and makes no commit; also works outside a repository. |
git send-email FILE | Email patch filesSends each patch as a mail; a directory or a revision list can be given in place of files. |
git imap-send | Upload patches to an IMAP folderReads a mailbox made by git format-patch from standard input and stores it in your drafts folder. |
git request-pull START URL | Write a pull request summaryPrints a summary of your changes since the start commit and where they can be pulled from. |
git quiltimport | Apply a quilt patch seriesApplies the series to the current branch, keeping patch order, boundaries and descriptions. |
Maintenance and repair 14
| Command | What it does |
|---|---|
git gc | Clean up and optimiseCompresses file revisions and removes unreachable objects to save disk space and speed things up. |
git maintenance run | Run maintenance tasks nowRuns the enabled maintenance tasks once; by default that is only gc. |
git fsck | Check repository integrityChecks that every object is valid and connected, and reports dangling or corrupt ones. |
git prune | Delete unreachable objectsRemoves loose objects that no ref can reach; normally git gc runs it for you. |
git repack | Pack loose objectsCombines objects not yet in a pack into one; with -a everything is rebuilt into a single pack. |
git pack-refs | Pack branch and tag refsStores many refs in the single file packed-refs rather than one file per ref. |
git count-objects | Count loose objectsReports how many unpacked objects exist and the disk space they take; -v gives more detail. |
git refs list | List referencesAlias of git for-each-ref: lists refs with filtering, sorting and custom formats. |
git archive -o latest.zip HEAD | Export a commit as an archiveWrites the files of the latest commit to latest.zip; the format follows the file extension. |
git bundle create file.bundle master | Pack history into one fileWrites master and its history to a file that another machine can clone or fetch from offline. |
git fast-export | Dump history as a streamWrites revisions in the text format that git fast-import reads back. |
git fast-import | Import a history streamReads commands and data from standard input and writes packfiles; normally driven by an importer. |
git bugreport | Create a bug report fileCollects system and repository details plus a questionnaire into one text file you can send to the Git list. |
git diagnose | Collect diagnostics as a zipPackages details of the machine, the Git client and the repository state into a zip archive. |
Other version control systems 6
| Command | What it does |
|---|---|
git svn clone http://svn.example.com/project/trunk | Clone a Subversion repositoryCreates a Git repository tracking that Subversion path; later changes flow both ways. |
git p4 clone P4-DEPOT-PATH | Clone a Perforce depotCreates a Git repository from one or more p4 depot paths. |
git cvsimport | Import a CVS repositoryNeeds cvsps version 2, which the manual calls deprecated; it suggests cvs2git for one-off imports. |
git cvsexportcommit COMMIT-ID | Export a commit to CVSApplies one Git commit to a CVS checkout and does not commit there by default. |
git cvsserver | Serve a repository to CVS clientsEmulation layer that lets CVS clients work against a Git repository; not every CVS method is implemented. |
git archimport | Import from GNU ArchImports one or more Arch repositories and marks merges where it can find the source branch. |
No row on this page matches that filter.
Notes
The 80% loop
Daily git is five commands: git status → git add PATHSPEC → git commit → git pull → git push. The habit that prevents most accidents is running git status before and after anything else — it tells you the branch, what's staged, and what would be committed. git add . stages everything under the current directory; prefer naming files (git add PATHSPEC) when a change set mixes concerns, and let git log --oneline be the sanity check that history looks the way you think it does.
Branching: cheap to make, cheap to delete
git checkout -b NEW-BRANCH creates and switches in one step (newer git also offers git switch -c NEW-BRANCH). Merging brings a branch's work in with history intact; git rebase replays your commits on top of another branch for a linear history — the working rule is to rebase only commits that haven't been pushed anywhere shared, because rebase rewrites them. git branch -d BRANCH-NAME deletes a merged branch and refuses an unmerged one; that refusal is a feature, not an obstacle.
The undo toolbox, sorted by blast radius
Gentlest first: git stash shelves uncommitted work and git stash pop restores it — ideal for “wrong branch” moments. git restore --staged PATHSPEC unstages without touching the file's contents. git cherry-pick COMMIT copies a single commit onto the current branch. At the destructive end, git reset --hard HEAD^ deletes the last commit and its changes from the working tree — use it only when you truly want the work gone, and remember committed-then-reset work is recoverable via git reflog for a grace period.
Questions
What is the difference between git fetch and git pull?
fetch downloads remote changes without touching your working branch; pull runs fetch and then integrates the upstream branch into the current one. By default pull only fast-forwards: git pull --rebase or git pull --no-rebase picks a rebase or a merge when the branches have diverged. Fetch first when you want to inspect before integrating.
When should I rebase instead of merge in git?
Rebase local, unpushed commits to keep history linear; merge anything already shared. Rewriting pushed commits forces everyone else to untangle it.
What does git stash actually store?
Uncommitted tracked changes (staged and unstaged). git stash pop restores the most recent stash and drops it; git stash apply restores but keeps it in the stash list.
How do I copy one commit to another branch?
git cherry-pick <hash> from the target branch. It creates a new commit with the same changes — the original stays where it was.
Why won't git branch -d delete my branch?
-d refuses if the branch isn't merged, protecting unmerged work. If you're certain, -D force-deletes.
How do I get stashed changes back in Git?
Run git stash pop. It applies the most recent stash to the working tree and removes that entry from the stash list. git stash apply does the same but keeps the entry, which is the safer choice when the same changes are needed on more than one branch.
git stash list shows every entry, the newest as stash@{0}. Name an entry to restore an older one, for example git stash pop stash@{1}. If the pop stops on a conflict the entry is not removed: resolve the conflict, then delete it with git stash drop.
How do I undo the last Git commit?
Run git reset HEAD~1 to remove the last commit and keep its changes as unstaged edits in the working tree. git reset --soft HEAD~1 keeps them staged instead. git reset --hard HEAD~1 throws them away, together with any other uncommitted changes to tracked files.
If the commit has already been pushed to a shared branch, leave history alone: git revert HEAD adds a new commit that reverses it. After a reset made by mistake, git reflog shows where HEAD pointed before, and resetting to that entry brings the commit back.
Sources and checks
- Git 2.56.0 manual: git(1), the top-level manual page List of Git commands with one-line descriptions; cited for git blame, git grep, git apply
- Git 2.56.0 manual: gittutorial(7), A tutorial introduction to Git First-time setup and basic examples; cited for git config, git add, git reset
- Git 2.56.0 manual: git-config(1) Synopsis, options and examples of git config
- Git 2.56.0 manual: git-help(1) Synopsis, options and examples of git help
- Git 2.56.0 manual: git-version(1) Synopsis, options and examples of git version; also cited for git
- Git 2.56.0 manual: git-init(1) Synopsis, options and examples of git init
80 more source pages
- Git 2.56.0 manual: git-clone(1) Synopsis, options and examples of git clone; also cited for git submodule
- Git 2.56.0 manual: git-fetch(1)
- Git 2.56.0 manual: git-status(1) Synopsis, options and examples of git status
- Git 2.56.0 manual: git-add(1) Synopsis, options and examples of git add
- Git 2.56.0 manual: git-commit(1) Synopsis, options and examples of git commit
- Git User's Manual (Git 2.56.0 documentation) Worked examples from the user manual; cited for git commit, git log
- Git 2.56.0 manual: git-rm(1) Synopsis, options and examples of git rm
- Git 2.56.0 manual: git-mv(1) Synopsis, options and examples of git mv
- Git 2.56.0 manual: git-gui(1) Synopsis, options and examples of git gui
- Git 2.56.0 manual: git-citool(1) Synopsis, options and examples of git citool
- Git 2.56.0 manual: git-diff(1) Synopsis, options and examples of git diff
- Git 2.56.0 manual: git-difftool(1) Synopsis, options and examples of git difftool
- Git 2.56.0 manual: git-range-diff(1) Synopsis, options and examples of git range-diff
- Git 2.56.0 manual: git-branch(1) Synopsis, options and examples of git branch
- Git 2.56.0 manual: git-switch(1) Synopsis, options and examples of git switch
- Git 2.56.0 manual: git-checkout(1) Synopsis, options and examples of git checkout
- Git 2.56.0 manual: git-merge(1) Synopsis, options and examples of git merge
- Git 2.56.0 manual: git-mergetool(1) Synopsis, options and examples of git mergetool
- Git 2.56.0 manual: git-merge-tree(1) Synopsis, options and examples of git merge-tree
- Git 2.56.0 manual: git-rerere(1) Synopsis, options and examples of git rerere
- Git 2.56.0 manual: git-remote(1) Synopsis, options and examples of git remote
- Git 2.56.0 manual: git-pull(1) Synopsis, options and examples of git pull
- Git 2.56.0 manual: git-push(1) Synopsis, options and examples of git push
- Git 2.56.0 manual: git-log(1) Synopsis, options and examples of git log
- Git 2.56.0 manual: git-show(1) Synopsis, options and examples of git show
- Git 2.56.0 manual: git-blame(1) Synopsis, options and examples of git blame
- Git 2.56.0 manual: git-annotate(1) Synopsis, options and examples of git annotate
- Git 2.56.0 manual: git-shortlog(1) Synopsis, options and examples of git shortlog
- Git 2.56.0 manual: git-describe(1) Synopsis, options and examples of git describe
- Git 2.56.0 manual: git-reflog(1) Synopsis, options and examples of git reflog
- Git 2.56.0 manual: git-grep(1) Synopsis, options and examples of git grep
- Git 2.56.0 manual: git-bisect(1) Synopsis, options and examples of git bisect
- Git 2.56.0 manual: git-show-branch(1) Synopsis, options and examples of git show-branch
- Git 2.56.0 manual: git-whatchanged(1) Synopsis, options and examples of git whatchanged
- Git 2.56.0 manual: gitk(1) Synopsis, options and examples of gitk
- Git 2.56.0 manual: git-instaweb(1) Synopsis, options and examples of git instaweb
- Git 2.56.0 manual: git-restore(1) Synopsis, options and examples of git restore
- Git 2.56.0 manual: git-reset(1) Synopsis, options and examples of git reset
- Git 2.56.0 manual: git-rebase(1) Synopsis, options and examples of git rebase; also cited for git reset
- Git 2.56.0 manual: git-revert(1) Synopsis, options and examples of git revert
- Git 2.56.0 manual: git-clean(1) Synopsis, options and examples of git clean
- Git 2.56.0 manual: git-stash(1) Synopsis, options and examples of git stash
- Git 2.56.0 manual: git-tag(1) Synopsis, options and examples of git tag
- Git 2.56.0 manual: git-verify-tag(1) Synopsis, options and examples of git verify-tag
- Git 2.56.0 manual: git-verify-commit(1) Synopsis, options and examples of git verify-commit
- Git 2.56.0 manual: git-notes(1) Synopsis, options and examples of git notes
- Git 2.56.0 manual: git-cherry-pick(1) Synopsis, options and examples of git cherry-pick
- Git 2.56.0 manual: git-history(1) Synopsis, options and examples of git history
- Git 2.56.0 manual: git-filter-branch(1) Synopsis, options and examples of git filter-branch
- Git 2.56.0 manual: git-replace(1) Synopsis, options and examples of git replace
- Git 2.56.0 manual: git-worktree(1) Synopsis, options and examples of git worktree
- Git 2.56.0 manual: git-submodule(1) Synopsis, options and examples of git submodule
- Git 2.56.0 manual: git-sparse-checkout(1) Synopsis, options and examples of git sparse-checkout
- Git 2.56.0 manual: git-backfill(1) Synopsis, options and examples of git backfill
- Git 2.56.0 manual: git-format-patch(1) Synopsis, options and examples of git format-patch
- Git 2.56.0 manual: git-am(1) Synopsis, options and examples of git am
- Git 2.56.0 manual: git-send-email(1) Synopsis, options and examples of git send-email
- Git 2.56.0 manual: git-imap-send(1) Synopsis, options and examples of git imap-send
- Git 2.56.0 manual: git-request-pull(1) Synopsis, options and examples of git request-pull
- Git 2.56.0 manual: git-quiltimport(1) Synopsis, options and examples of git quiltimport
- Git 2.56.0 manual: git-gc(1) Synopsis, options and examples of git gc
- Git 2.56.0 manual: git-maintenance(1) Synopsis, options and examples of git maintenance
- Git 2.56.0 manual: git-fsck(1) Synopsis, options and examples of git fsck
- Git 2.56.0 manual: git-prune(1) Synopsis, options and examples of git prune
- Git 2.56.0 manual: git-repack(1) Synopsis, options and examples of git repack
- Git 2.56.0 manual: git-pack-refs(1) Synopsis, options and examples of git pack-refs
- Git 2.56.0 manual: git-count-objects(1) Synopsis, options and examples of git count-objects
- Git 2.56.0 manual: git-refs(1) Synopsis, options and examples of git refs
- Git 2.56.0 manual: git-archive(1) Synopsis, options and examples of git archive
- Git 2.56.0 manual: git-bundle(1) Synopsis, options and examples of git bundle
- Git 2.56.0 manual: git-fast-export(1) Synopsis, options and examples of git fast-export
- Git 2.56.0 manual: git-fast-import(1) Synopsis, options and examples of git fast-import
- Git 2.56.0 manual: git-bugreport(1) Synopsis, options and examples of git bugreport
- Git 2.56.0 manual: git-diagnose(1) Synopsis, options and examples of git diagnose
- Git 2.56.0 manual: git-svn(1) Synopsis, options and examples of git svn
- Git 2.56.0 manual: git-p4(1) Synopsis, options and examples of git p4
- Git 2.56.0 manual: git-cvsimport(1) Synopsis, options and examples of git cvsimport
- Git 2.56.0 manual: git-cvsexportcommit(1) Synopsis, options and examples of git cvsexportcommit
- Git 2.56.0 manual: git-cvsserver(1) Synopsis, options and examples of git cvsserver
- Git 2.56.0 manual: git-archimport(1) Synopsis, options and examples of git archimport
Every row on this page was matched to a line in the documentation above on . A binding that could not be found there is not listed.
Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.