| 
                         Vim Fugitive 是另一个将 Git 工作流集成到 Vim 中的超棒插件。它对 Git 做了一些封装,可以让你在 Vim 里直接执行 Git 命令并将结果集成在 Vim 界面里。这个插件有超多的特性,更多信息请访问它的 GitHub 项目页面。 
这里有一个使用 Vim Fugitive 的基础 Git 工作流示例。设想我们已经对下面的 Go 代码做出修改,你可以用 :Gblame 调用 git blame 来查看每行最后的提交信息: 
e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    1 package maine9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    2e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    3 import "fmt"e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    4e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│_   5 func main() {e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    6     items := []string{"tv", "pc", "tablet"}e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    700000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│~   8     if len(items) > 0 {e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    9         for _, i := range items {e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   10             fmt.Println(i)00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│+  11             fmt.Println("------")e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   12         }e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   13     }e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   14 }
  
可以看到第 8 行和第 11 行显示还未提交。用 :Gstatus 命令检查仓库当前的状态: 
  1 # On branch master  2 # Your branch is up to date with 'origin/master'.  3 #  4 # Changes not staged for commit:  5 #   (use "git add <file>..." to update what will be committed)  6 #   (use "git checkout -- <file>..." to discard changes in working directory)  7 #  8 #       modified:   vim-5plugins/examples/test1.go  9 # 10 no changes added to commit (use "git add" and/or "git commit -a")--------------------------------------------------------------------------------------------------------    1 package main    2    3 import "fmt"    4_   5 func main() {    6     items := []string{"tv", "pc", "tablet"}    7~   8     if len(items) > 0 {    9         for _, i := range items {   10             fmt.Println(i)+  11             fmt.Println("------")   12         }   13     }   14 }
  
                        (编辑:91站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |