HEAD

cat .git/HEAD
ref: refs/heads/publish/0.0.4

撤销commit

git revert HEAD -m 'add' ;//撤销前一次 commit
git revert HEAD^ ;//撤销前前一次 commit

恢复某个已修改的文件(撤销未提交的修改):

$ git checkout file-name;//git ct ./src/pages/index/index.js

撤销所有更改

//撤销所有修改
$ git checkout .

git拉取远程分支并创建本地分支

git checkout -b local-branchname origin/remote_branchname 

git clone下来指定的单一分支

git clone -b <branch-name> --single-branch https://github.com/user/repo.git

删除.idea文件或某一指定文件

error: The following untracked working tree files would be overwritten by checkout:
.idea/workspace.xml

执行:

$ git rm -f --cached .idea/workspace.xml
$ git rm -rf file-name;//git递归删除指定文件

然后把.idea/workspace.xml添加到gitignore文件

git短命令注册

$ git config --global alias.st status

git pull与本地文件冲突:

git stash:暂存修改
git pull

版本回退 只需要添加commit版本号的前几位

git reset--hard 3628164
posted on 2017-03-26 23:39  Aarondm  阅读(96)  评论(0编辑  收藏  举报