Home  >  Article  >  Web Front-end  >  A complete list of common git commands

A complete list of common git commands

一个新手
一个新手Original
2017-09-26 10:15:141486browse


Initialize a warehouse

$ mkdir learngit
$ cd learngit
$ pwd               //显示当前目录
$ git init          //把文件变成git可管理文件

Submit files to the warehouse

$ git add 文件名
$ git commit -m "文件的描述"

You can add multiple files , commit once.

Check the current status

$ git status

Check the difference from before

$ git diff +文件名

Note that you still need to commit again after modifying the file, steps Same as the previous submission

View the commit log from the latest to the farthest

$ git log
$ git log --pretty=oneline //查看精简的信息

Return to the previous version (status)

$ git reset --hard HEAD^   
$ git reset --hard id  //id是commit id(版本号)

HEAD represents the current version, the previous version is HEAD^, the previous version is HEAD^^, and so on...

Record every command you make

$ git reflog      //退回到上一个版本还能再返回来

The above is the detailed content of A complete list of common git commands. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn