2022-7-28 19:43 /
                                _______

                                 MAGIT
                                _______


Table of Contents
_________________

1. 资源
2. Basic
3. Advanced
.. 1. Branch
.. 2. Rebase
.. 3. Log and reflog
.. 4. Others (Stash, Tag)





1 资源
======

  基本用法: [Everyday Git Workflow in Emacs with Magit]

  进阶用法:[Fix Your Git Commits Like a Rebase Expert with Magit]

  cherry-pick: [How to easily cherry pick with magit?]


[Everyday Git Workflow in Emacs with Magit]
<https://systemcrafters.cc/mastering-git-with-magit/everyday-git-workflow/>

[Fix Your Git Commits Like a Rebase Expert with Magit]
<https://www.youtube.com/watch?v=zM7K1y4h6UQ&list=PLEoMzSkcN8oMc34dTjyFmTUWbXTKrNfZA&index=3>

[How to easily cherry pick with magit?]
<https://emacs.stackexchange.com/questions/10611/how-to-easily-cherry-pick-with-magit>


2 Basic
=======

  -------------------------------------------------------
   h              help                                   
   magit-status   打开magit status                       
   magit-clone    clone repo                             
   s              stage                                 
   u              unstage                                
   k              disgard                                
   g              刷新                                   
  -------------------------------------------------------
   c              Commit                                 
   c c            commit提交                             
   c e            (extend) amend without message         
   c a            amend with message                     
   c w            (reword) just change message           
   c F + C-c C-c  (Fix up) add changes to earlier commit
  -------------------------------------------------------
   x              Reset (时光回溯!)                    
   X              Reset !                                
   x h            hard reset                             
  -------------------------------------------------------
   M              Remote                                 
   M a            添加 remote                           
   M C            配置 remote                           
  -------------------------------------------------------
   P              push                                   
   P p            push to remote                        
   P -f p         force-pushing                          
  -------------------------------------------------------
   f              fetch branch withou pulling            
   f p            fetch from remote                     
   f u            fetch from upstream                    
  -------------------------------------------------------
   F              Pull                                   
   F p            pull the latest commit from remote     
   F u            pull from upstream branch              
   F e            Pull from select branch               
   F r            pull branch with rebase               
  -------------------------------------------------------


3 Advanced
==========

  branch, rebasing, cherry picking, managing the reflog


3.1 Branch
~~~~~~~~~~

  -------------------------------------------------------------------------
   b    Branch                                                            
   b n  magit-branch-create new branch                                    
   b c  create magit bracch and check it out!                              
   b l  checkout 选定的branch (在所有branch列表中选择)                     
   b b  magit-checkout branch,可在log界面中操作                           
   b s  (spinoff) create new branch and reset master back to remote commit
  -------------------------------------------------------------------------


3.2 Rebase
~~~~~~~~~~

  分支A rebase 分支B的意思就是: 让分支A 在分支B 所有commit的基础上再做
  更改。
  -------------------------------------------------------
   r    Rebase                                          
   r i  rebase interactively. 直接无敌!                 
   r r  continue the rebase option after solve conflicts
  -------------------------------------------------------
  在 `r i' 交互界面里,非常的离谱!直接无敌!你可以:
  - Reword comments 修改comment
  - Drop commit 抛弃指定的commits
  - Edit commits 重新编辑和修改指定的commit
  - Reorder commits 为commits重新排序
  - Combine commits 把多个commits合成一个,sqush 和 fixup (不保留当前
    comment)的区别。

  一般的,在做好rebase 相关操作后都是通过 `r r' 来提交和完成。


3.3 Log and reflog
~~~~~~~~~~~~~~~~~~

  ------------------------------------------
   l    Log                                 
   l l  magit-log-current 查看当前分支的log
   l o  magit-log-other 查看其他分支的log   
   l r  git reflog                          
  ------------------------------------------
  Magit 在log日志界面的状态下,允许做很多amazing的操作

  ------------------------------------------------------------
   d             See differencce of that commit               
   b b <return>  checkout commit                              
   x             reset branch to current ccommit              
   A A           cherry-pick specific changes to other branch
   r i           打开rebase 交互界面                          
  ------------------------------------------------------------
  更离谱的是可以选择区域,然后 `A A' ,能cherry-pick 多个changes 到指定
  的branch。


3.4 Others (Stash, Tag)
~~~~~~~~~~~~~~~~~~~~~~~~~~

  ------------------------------------------------
   z    Stash                                    
   z z  stash -> both                             
   z p  stash -> pop                              
   z a  stash -> apply                           
  ------------------------------------------------
   t    Tag                                       
   t t  add tag 添加标签                          
   i    Ignore                                    
   i t  add the file to the repo-level .gitignore
Tags: emacs magit