[Git]常用命令

Git 常用命令

查看提交历史

git log  
--pretty
git log --pretty=oneline -n
git log --pretty=format:"%h %s" --graph

放弃更改

  1. 当文件未被放入暂存区

    git checkout -- <filepath>
    git checkout -- .    
  2. 文件已经放入暂存区

     git reset HEAD <filepath>
     git reset HEAD .    
  3. 文件已经提交commit

    git reset --hard <commitid>
    git reset --hard HEAD^

新建分支

git branch <name>
git checkout <name>

# 或者新建并切换:
git checkout -b <name>

猜你喜欢

转载自www.cnblogs.com/wtlife/p/11975275.html