Emacs: Version Control Commands (git)
2023-08-28
2023-09-24
xtodo
work in progress.
Start to look at vc* commands in emacs, since i stop using magit.
the vc commands can work with several version control systems.
here, we explain it assuming you are using git. 〔see Practical in 1 Hour〕
Version Control Main Commands
vc-dir【C-x v d】-
Show status of changed files.
(Similar to
git status)The output buffer is shown in major mode
vc-dir-mode- 【m】 → mark the file on current line.
- 【u】 → unmark a file.
- 【M】 → mark all files of the same state.
- 【U】 → unmark all files of the same state.
- 【i】 →
vc-register(likegit add) - 【P】 →
vc-push(likegit push) - 【+】 →
vc-update(likegit pull) - 【=】 →
vc-diff(likegit diff)
- For more commands, Alt+x
describe-mode(vc-dir-mode_keys.txt)
emacs 29 M-x vc-dir 2023-08-28
vc-register【C-x v i】-
Similar to
git add vc-push【C-x v P】-
Similar to
git push vc-update【C-x v +】 (alias ofvc-pull)-
Similar to
git pull
Show File Difference Commands
vc-diff【C-x v =】-
show diff between file revisions.
of current file, with git backend, show the difference of current file with last commit.
emacs vc-diff 2021-09-21 vc-version-diff- show diff between file revisions.
vc-ediff- show diff between file revisions using ediff.
vc-version-ediff- show diff between file revisions using ediff.
vc-diff-mergebase【C-x v M D】- Report diffs between the merge base of REV1 and REV2 revisions.
vc-root-diff【C-x v D】- Display diffs between VC-controlled whole tree revisions.
vc-root-version-diff- Report diffs between REV1 and REV2 revisions of the whole tree.
Show Log
vc-print-logC-x v l-
show the change log of the current file.
- 【d】 to show diff of current commit id.
emacs 29 vc-print-log 2023-09-24 DtNf vc-print-root-logC-x v L-
show the change log of the current repo.
- 【d】 to show diff of current commit id.
emacs 29 vc-print-root-log 2023-09-24 TWmk vc-print-branch-log- Show the change log for BRANCH in a window.
Git Specific Commands
vc-git-grep- Run git grep, searching for REGEXP in FILES in directory DIR.
vc-git-log-edit-mode- Major mode for editing Git log messages.
vc-git-log-edit-toggle-amend- Toggle whether this will amend the previous commit.
vc-git-log-edit-toggle-no-verify- Toggle whether to bypass the pre-commit and commit-msg hooks.
vc-git-log-edit-toggle-signoff- Toggle whether to add the "Signed-off-by" line at the end of
vc-git-log-view-mode- Major mode derived from `log-view-mode' by `define-derived-mode'.
vc-git-region-history-mode- Major mode to browse Git's "log -p" output.
vc-git-stash- Create a stash given the name NAME.
vc-git-stash-apply- Apply stash NAME.
vc-git-stash-apply-at-point- Apply the stash at point.
vc-git-stash-delete- Delete stash NAME.
vc-git-stash-delete-at-point- Delete the stash at point.
vc-git-stash-menu- (not documented)
vc-git-stash-pop- Pop stash NAME.
vc-git-stash-pop-at-point- Pop the stash at point.
vc-git-stash-show- Show the contents of stash NAME.
vc-git-stash-show-at-point- Show the stash at point.
vc-git-stash-snapshot- Create a stash with the current tree state.
Other VC Commands
- 【S】 →
vc-dir-searchsearch marked files - 【Q】 →
vc-dir-query-replace-regexpfind replace on the marked files
vc-annotateC-x v g-
Display the edit history of the current FILE using colors.
emacs 29 vc-annotate 2023-09-24 GR2S vc-create-tagC-x v s- Descending recursively from DIR, make a tag called NAME.
vc-delete-fileC-x v x- Delete file and mark it as such in the version control system.
vc-find-conflicted-file- Visit the next conflicted file in the current project.
vc-find-file-hook- Refresh the VC state of the current buffer's file.
vc-insert-headers- Insert headers into a file for use with a version control system.
vc-log-incomingC-x v I- Show a log of changes that will be received with a pull operation from REMOTE-LOCATION.
vc-log-mergebaseC-x v M L- Show a log of changes between the merge base of REV1 and REV2 revisions.
vc-log-outgoingC-x v O- Show a log of changes that will be sent with a push operation to REMOTE-LOCATION.
vc-log-search- Search the log of changes for PATTERN.
vc-mergeC-x v m- Perform a version control merge operation.
vc-mode-line- Set `vc-mode' to display type of version control for FILE.
vc-next-actionC-x v v- Do the next logical version control operation on the current fileset.
vc-refresh-state- Refresh the VC state of the current buffer's file.
vc-region-historyC-x v h- Show the history of the region between FROM and TO.
vc-rename-file- Rename file OLD to NEW in both work area and repository.
vc-resolve-conflicts- Invoke ediff to resolve the conflicts.
vc-retrieve-tagC-x v r- For each file in or below DIR, retrieve their tagged version NAME.
vc-revertC-x v u- Revert working copies of the selected fileset to their repository contents.
vc-revision-other-windowC-x v ~- Visit revision REV of the current file in another window.
vc-switch-backendC-x v b- Make BACKEND the current version control system for FILE.
vc-update-change-logC-x v a- Find change log file and add entries from recent version control logs.