Git study notes 00-- basic commands

Learning materials: git Liao Xuefeng

Git: distributed version control system

CVS, SVN: centralized version control system

1. Install Git: yum -install git 

2. Create Repository:

  (1) new directory: mkdir newgit ps: windows of the path to avoid Chinese

  (2) git init command directory is initialized to the warehouse, which is used to track .git directory management repository

3. Add files to the repository

  (1) git add + file name, add files to the repository

  (2) git commit -m "balabal", the file will be submitted to the warehouse parameters -m + "wrote a readme file"; information display change command is executed. git commit may submit multiple files at once.

Supplement: git only track text files (there are encoded txt, web pages, program code, etc.) changes, change tracking does not support binary files (pictures, videos, word documents).

4. Review and modify the contents of the warehouse status

git status: View the current state of the repository

View modify the contents of the file: git diff + filename

 5. version rollback

git log command: View commit history, parameter --pretty = oneline can make the output more intuitive.

git reset --head + version information: roll back a particular version, which represents the current version HEAD, HEAD ^ on a version, the previous version HEAD ^^, then the previous version is represented HEAD ~ xx (xx is a number , XX represents a version prior to the current version)

Version rollback process scenarios:

(1) fall back to the previous version: the above method, pay attention to rollback the latest version information will not appear in the log.

(2) fall back to the old version and then regret it, to fall back to the previous version of the new:

Case 1: soon regret, the window is not closed: git reset --hard version number (several former commit id write like)

Case 2: afterwards regret: git reflog command: record your every command can find the commit id.

问题小结:vim编辑警告:warning: LF will be replaced by CRLF in addtest.txt.

原因:Git的换行符价检查功能,LF为Linux下换行符\n,CRLF为回车\r+换行\n(windows下结束一行)。

解决方法:配置git config文件

git config --global core.autocrlf +参数;

参数false 不做任何检查,保持原样;参数input会在add时把CRLF转换成LF,checkout时依然是LF(windows不建议设置此值);参数true在add时将CRLF转换成LF,checkout时再将文件的LF转换为CRLF。

要避免每次看到提示,则可改为false。

 

 

Guess you like

Origin www.cnblogs.com/gongweichao/p/11914653.html