<commit_before>---
title: 玩转git
date: 2016-07-02 20:37:32
categories: linux-env
tags:
  - SCM
---

Let's play with git ^^

<!--more-->

# git config #
* git config的操作
  - --global: 对所有git repo, 否则只会影响当前git repo的.git/config文件.
  - --unset: 删除alias.XX的设置
```
# git config --unset alias.XX YY_ZZ_UU
```
* git config user.name "your name"
* git config user.email yourname@email_server
* git config core.editor vim
  - 默认情况下git会使用默认编辑器,如果想指定与系统不同的编辑器.
  - 就会在.git/config中增加如下内容.(当然,手动改的话也是可以的)
```
[core]
	editor = vim
```
* git config core.paper "less -N"
  - use "less" with number
```
man less

       -N or --LINE-NUMBERS
              Causes  a  line  number to be displayed at the beginning of each
              line in the display.
```
* git config color.diff true
  - set color for diff
* git config alias.XX YY_ZZ_UU
  - git XX == git YY_ZZ_UU
```
git config --global alias.ci commit
git config --global alias.cia 'commit --amend'
git config --global alias.rs reset
git config --global alias.rh 'reset --hard'
git config --global alias.rp 'reset HEAD^'
git config --global alias.st status
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.lo 'log --oneline'
git config --global alias.cl 'clean -df'
git config --global alias.pr 'pull --rebase'
git config --global alias.rbc 'rebase --continue'
git config --global alias.rb rebase
```
* git config core.autocrlf true
```
If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever you git checkout something, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.

The side-effect of this convenient conversion, and this is what the warning you're seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a "for your information" in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.

If core.autocrlf is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

My personal preference is to leave the setting turned ON, as a Windows developer.<commit_msg>[git] update git config settings<commit_after>---
title: 玩转git
date: 2016-07-02 20:37:32
categories: linux-env
tags:
  - SCM
---

Let's play with git ^^

<!--more-->

# git config #
* git config的操作
  - --global: 对所有git repo, 否则只会影响当前git repo的.git/config文件.
  - --unset: 删除alias.XX的设置
```
# git config --unset alias.XX YY_ZZ_UU
```
* git config user.name "your name"
* git config user.email yourname@email_server
* git config core.editor vim
  - 默认情况下git会使用默认编辑器,如果想指定与系统不同的编辑器.
  - 就会在.git/config中增加如下内容.(当然,手动改的话也是可以的)
```
[core]
	editor = vim
```
* git config core.paper "less -N"
  - use "less" with number
```
man less

       -N or --LINE-NUMBERS
              Causes  a  line  number to be displayed at the beginning of each
              line in the display.
```
* git config color.diff true
  - set color for diff
* git config alias.XX YY_ZZ_UU
  - git XX == git YY_ZZ_UU
```
git config --global alias.ci commit
git config --global alias.rs reset
git config --global alias.st status
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.lo 'log --oneline'
git config --global alias.rt remote
git config --global alias.rb rebase
git config --global alias.cp cherry-pick
git config --global alias.rh 'reset --hard'
git config --global alias.cl 'clean -df'
git config --global alias.lou 'log --pretty=oneline --format="%h %s <%an>"'
git config --global alias.ar 'apply --reject'
git config --global alias.la 'log --pretty=oneline --format="%Cred%h%Creset %Cblue%ci%Creset %s %Cgreen<%an>"'
git config --global alias.arp 'apply --reject .git/rebase-apply/patch'
git config --global alias.rp 'reset HEAD^'
git config --global alias.rph 'reset --hard HEAD^'
git config --global alias.dc 'describe --contains'
git config --global alias.se 'send-email'
git config --global alias.pr 'pull --rebase'
git config --global alias.pusha 'push gerritgit HEAD:refs/for/`git rev-parse --abbrev-ref HEAD`'
git config --global alias.cia 'commit --amend'
git config --global alias.aa 'add -A'
git config --global alias.sh stash
git config --global alias.rbi 'rebase -i'
git config --global alias.rbc 'rebase --continue'
git config --global alias.cpc 'cherry-pick --continue'
git config --global alias.ann annotate
git config --global alias.diffc 'diff --cached'

git config --global sendemail.smtpserver 'xyz.abc.com'
git config --global sendemail.smtpserverport 25

```
* git config core.autocrlf true
```
If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever you git checkout something, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.

The side-effect of this convenient conversion, and this is what the warning you're seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a "for your information" in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.

If core.autocrlf is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

My personal preference is to leave the setting turned ON, as a Windows developer.
{'fraction_non_alphanumeric': 0.08537121101186118, 'fraction_numerical': 0.004393029726167814, 'mean_word_length': 3.5594125500667557, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2989286', 'n_tokens_mistral': 2127, 'n_tokens_neox': 2040, 'n_words': 987}