仓库相关:
查看远程仓库中的所有地址
git remote -v
分支相关:
查看全部分支
git branch -a
新建一个分支,但依然停留在当前分支$ git branch [branch-name]
新建一个分支,并切换到该分支$ git checkout -b [branch]
新建一个分支,指向指定commit $ git branch [branch] [commit]
新建一个分支,与指定的远程分支建立追踪关系
git branch --track [branch] [remote-branch]
合并指定分支到当前分支
git merge [branch]
选择一个commit,合并进当前分支
git cherry-pick [commit]
删除分支$ git branch -d [branch-name]
删除远程分支
git push origin --delete [branch-name]
git branch -dr [remote/branch]
git log --pretty=oneline:查看Git版本提交信息,值只显示版本唯一HEAD和提交备注信息(是Git log的简版),后提交的在上面;
Git reset --hard HEAD:回滚到指定的版本,HEAD对应为版本的唯一ID号(HEAD ID可以只写前6位)。
Git reset --hard HEAD^:回滚到上一个版本
Git reflog
如果在回退以后又想再次回到之前的版本,git reflog 可以查看所有分支的所有操作记录(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录。
缓存操作相关
git rm
$ git rm [file1] [file2] ...
删除工作区文件,并且将这次删除放入暂存区
历史操作记录相关
git log
查看当前仓库基本信息。
git remote show origin