VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > c#教程 >
  • C#教程之C#教程之Git使用笔记

本站最新发布   C#从入门到精通
试听地址  
https://www.xin3721.com/eschool/CSharpxin3721/

使用VIM编辑commit注释信息

在命令输入模式下面,输入字母”i”,则VIM进入到插入模式,接着输入自己的注释内容;

完成注释后需要退出:

1)按键Esc,如果无效,连续按两次

2)当底部提示行出现空白时,输入冒号“:”

3)再输入字母“q”,回车 (输入wq,为保存退出)

但是实际上使用vim非常不方便,

好吧,我是在设置其他编辑器失败后没有办法才有那么几天被迫使用了vim…

修改默认编辑器

关于默认编辑器最好是安装git之前你就已经安装了响应的编辑器比如notepad++或VS Code,这样就可以在安装git的时候直接在安装配置界面中配置。如果在安装完了git后再要修改默认编辑器参照如下:

 

在git中设置默认使用的文本编辑器为notepad++

$ git config --global core.editor notepad++

设置成功会如下显示。

$ git config --global core.editor 
notepad++

有的时候设置不成功,提交的时候不弹出notepad++,可以再使用如下命令试试

git config --global core.editor "'D:\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"

 

将默认编辑器修改为VS Code

git config --global core.editor "code -w"

设置成功会如下显示。

$ git config --global core.editor
code -w

 

设置了编辑器后,commit时编辑器打开了但是bash中提示提交取消

$ git commit
Aborting commit due to empty commit message.

查找到StackOverflow上说法

When you set an editor in the configuration of Git, make sure to pass the parameter "-w" to force Git to wait your commit message that you would type on your custom editor.

相应的做法是设置编辑器的时候加上-w参数

For Visual studio Code

git config --global core.editor "code -w"

For atom

git config --global core.editor "atom -w"

For sublime

git config --global core.editor "subl -w"

 

但是有时候即使我们加了-w参数也不成功或者说会报如下错误:

$ git config --global core.editor "Code -w"
 warning: core.editor has multiple values
 error: cannot overwrite multiple values with a single value
        Use a regexp, --add or --replace-all to change core.editor.

这个时候需要重置git的编辑器设置然后重新设置编辑器

git config --global --unset-all core.editor
git config  --unset-all core.editor
git config --global core.editor "code -w"

这样操作之后终于把问题解决了,设置成功后提交时会提示如下:

$ git commit
hint: Waiting for your editor to close the file...

Ref:Aborting commit due to empty commit message

Git 放弃本地修改

见文章《git 放弃本地修改

Git 放弃先前提交

要讲某一次commit抹去可以使用如下命令

>> git reset –hard commit_hash

执行完该命令后便将当前分支回退到commit_hash那一次提交了,在这次提交后面的所有提交都将被彻底抹去不留痕迹,为非常危险的操作

如果你想要放弃已经提交到服务器上得到提交,可以在本科执行该命令达到目的后然后强行push

>> git push –force

这是个更加危险的操作,因为你抹去的是服务器上的版本,你的同事可能会去买枪的哦

 

Github Git彻底删除历史提交记录的方法

 

Git 查看某个commit中某一文件的改动

通过git blame命令可以查看某一次commit中具体某文件中都做了哪些修改,详见

git查看某个文件某些行的改动 git blame

Git diff 的使用

To be explored………………………………..

https://www.cnblogs.com/qianqiannian/p/6010219.html

http://www.cnblogs.com/xiaodi-js/p/7215250.html

Git clean 的使用

>> git clean –fdx

使得仓库中所有没有被追踪的文件和文件夹都删除,回到如同刚clone下来一样的干净状态

Git 持续集成

基于Gitlab CI搭建持续集成环境

Gitlab CI yaml官方配置文件翻译

 

相关链接收藏

A successful Git branching model

A successful Git branching model/GIT分支管理是一门艺术

泪流满面的 11 个 Git 面试题

Git-Book

相关教程