Emacs plug in (3) — version management Magit

Time:2021-5-10

1、 Reference

Contents of Emacs series articles — updating

A walk through the Magit interface

2、 Basic use

2.1 magit status

C-x gget intomagit status, similar togit status

Emacs plug in (3) -- version management Magit

Emacs plug in (3) -- version management Magit

Emacs plug in (3) -- version management Magit

As you can see,magit statusWill display more content thangit status

2.2 hide extension tab

aboutmagit statusEach part of can be usedtabKey to hide or expand the current content

be careful:

(1) Inmagit statusYou can use thegRefresh currentgitWarehouse status

Emacs plug in (3) -- version management Magit

(2) Can useGRefresh allmagit status buffer

Emacs plug in (3) -- version management Magit

(3) But usually, there is no need to refresh. In the current project,magit statusIt will refresh automatically as the file changes

2.3 movement between different parts

(1) Movement between rows

c-nnext row
Emacs plug in (3) -- version management Magit

c-pprevious line
Emacs plug in (3) -- version management Magit

(2) Movement between parts

m-pPrevious section
Emacs plug in (3) -- version management Magit

m-nNext section
Emacs plug in (3) -- version management Magit

2.4 commit buffer

seecommitdetails

Emacs plug in (3) -- version management Magit

staycommitFor details, you can2.3 movement between different partsMove

commandqWill exit the currentcommit buffer

(1) Direct useenterget intocommit buffer, will containcommitInformation and change information

Emacs plug in (3) -- version management Magit

2.5 magit diff

Using commandsddget intocommit buffer, will only containcommitChange information for

Step one:magit diffget intodiffScreen interface

Emacs plug in (3) -- version management Magit

Step 2:dexpressDwin, dwinyesdo what i meanAbbreviation for

Emacs plug in (3) -- version management Magit

Emacs plug in (3) -- version management Magit

2.6 magit log

Step 1: use the commandlget intocommit log

Emacs plug in (3) -- version management Magit

Step 2:lShow currentcommit log

Emacs plug in (3) -- version management Magit
Emacs plug in (3) -- version management Magit

2.7 operation of reserved area

(1) Add changes to reservesmagit-stage

Emacs plug in (3) -- version management Magit

(2) Undo changes from reservationmagit-unstage

Emacs plug in (3) -- version management Magit

(3) Undo operationgit discard

Emacs plug in (3) -- version management Magit

3、 Submit

3.1 magit-commit

(1) magit-commitperhapscTo enter the submit option

Emacs plug in (3) -- version management Magit

Emacs plug in (3) -- version management Magit

(2) After entering the submit page,

How to use parameters (input first)-, and then enter the specific parameter characters)

a. Execute the command againcTo create a newcommit

Emacs plug in (3) -- version management Magit

b. Or carry out ordersa, equivalent togit commit --amend

(3) In the submit information editing interface,

a. Submit commandwith-editor-finish

Emacs plug in (3) -- version management Magit

b. Cancel this submissionwith-editor-cancel

Emacs plug in (3) -- version management Magit

4、 Rebase

5、 Merge

Emacs plug in (3) -- version management Magit

6、 Fetch / pull / push

6.1 magit fetch

Emacs plug in (3) -- version management Magit

6.2 magit pull

Emacs plug in (3) -- version management Magit

6.3 magit push

Emacs plug in (3) -- version management Magit

7、 Branches

7.1 magit-branch

staymagit-statusIn this state,bget intomagit-branchAdministration

Emacs plug in (3) -- version management Magit

Emacs plug in (3) -- version management Magit

7.2 branch checkoutpart

Subcommand explain other
c (new branch) Emacs plug in (3) -- version management Magit Emacs plug in (3) -- version management MagitEmacs plug in (3) -- version management Magit Equivalent to an ordergit checkout -b dev origin/devFrom the far endorigin/devFork and create a local branchdev
b (branch/revision) Emacs plug in (3) -- version management Magit Emacs plug in (3) -- version management Magit git checkout branchName

8、 Error resolution

8.1 wrong-type-argument transient-suffix

Seeissue,

The specific solution is to recompiletransient.el,

The recompilation method isSpecific file path of M-X byte compile file

8.2 GitError! refusing to merge unrelated histories

Emacs plug in (3) -- version management Magit

Using commandsgit pull --allow-unrelated-histories

git pull --allow-unrelated-histories
CONFLICT (add/add): Merge conflict in .gitignore
Auto-merging .gitignore
Automatic merge failed; fix conflicts and then commit the result.

9、 Usage scenarios

9.1 add operation

(1) Three areas

becausegitThere are three areas in the map

working directory, which is the current edit directory

staging area , which can be accessed throughgit add fileNameAdd files to staging area

Git local warehouse, which can be accessed throughgit commitAdd files from staging area to local warehouse

(2) FromNot tracked,Tracked but not stagedBecomeTemporary state

name explain
command magit-stage
Git command git add
Shortcut key s
file Emacs plug in (3) -- version management Magit

(3) FromIt has been temporarily storedBecomeSubmittedstate

name explain
command magit-commit
Git command git commit
Shortcut key c-c
file Emacs plug in (3) -- version management MagitEmacs plug in (3) -- version management Magit
Submit Emacs plug in (3) -- version management Magit

(4) FromLocal git warehouseSync toRemote git warehouse

name explain
command magit-merge
Git command git merge
Shortcut key m m
file Emacs plug in (3) -- version management MagitEmacs plug in (3) -- version management Magit
current state Emacs plug in (3) -- version management Magit
Post execution status Emacs plug in (3) -- version management Magit
name explain
command magit-pull
Git command git pull
Shortcut key F u
file Emacs plug in (3) -- version management MagitEmacs plug in (3) -- version management Magit
current state Emacs plug in (3) -- version management Magit
Post execution status Emacs plug in (3) -- version management Magit
name explain
command magit-push
Git command git push
Shortcut key P u
file Emacs plug in (3) -- version management MagitEmacs plug in (3) -- version management Magit
current state Emacs plug in (3) -- version management Magit
Post execution status Emacs plug in (3) -- version management Magit

9.2 revocation

(1) working directoryDelete files from

name explain
command magit-discard
Git command rm -rf fileName
Shortcut key k
file Emacs plug in (3) -- version management Magit
current state Emacs plug in (3) -- version management Magit
Post execution status Emacs plug in (3) -- version management Magit

(2) Bystaging area Undo toworking directory

name explain
command magit-unstage
Git command git restore
Shortcut key u
file Emacs plug in (3) -- version management Magit
current state Emacs plug in (3) -- version management Magit
Post execution status Emacs plug in (3) -- version management Magit