git使用记录

来源:互联网 发布:鸟倦飞而知还的而用法 编辑:程序博客网 时间:2024/06/07 23:52

记录一些git使用技巧。

1.设置显示提交记录:

在.gitconfig文件中添加:

[alias]
lg = log --all --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(bold white)%s%C(reset) %C(yellow)—%an%C(reset)%C(bold yellow)%C(auto)%d' --abbrev-commit --date=relative --show-signature --branches


2.拉取代码之后要强制更新成最新

git checkout -B yourBranch origin/master

切换到其他commit也是同理。只需要将origin/master替换成commitid


3.本地有未保存的代码是无法进行强制更新的操作的。可以先add commit 。然后再强制更新。


4.git reset --hard  commitId  强制切换到某个commit 


5.git reflog  查看记录,可以找到丢失的commitId


6.在windows 上使用git的时候,本地文件换行方式会自动变为CRLF换行方式。

原因:

在git版本库中,所有的文件换行符都LF。

git为了兼容windows,设置了一个autocrlf选项,默认为true。这个选项的作用是,将你从git上拉取的文本文件的换行符自动转换为windows上使用的CRLF。

在不需要的时候可以设置:
git config --global core.autocrlf false


7.



原创粉丝点击