Skip to content

git常用指令

L edited this page Apr 23, 2020 · 11 revisions

安装

git下载
tortoisegit
安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功
安装完成后,还需要最后一步设置,在命令行输入:

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

使用小乌龟,在拉代码(私有库)的时候会要求输入

回滚到某一版本

git checkout version

回滚到某版本,并删除之后的提交

git reset --hard commitid
git push -f origin 分支名

撤销本地commit

git reset --hard commit_id 

保留本地修改,到达目标版本

rebase会把你所有本地的commit叠加到你选定的版本之后
参考资料:
git rebase简介(基本篇)

fork相关步骤

在GitHub上面看上某个仓库,fork了它的当前版本(1.0)
然后在自己的同名仓库中开始开发一些功能,并提交到了自己的仓库
可以提交Pull Request给原仓库,等待作者合并
之后原仓库产生了新的提交(比如,版本变为了1.1),需要从原仓库拉新代码到自己的仓库
这一步需要把pull的目标从自己的仓库改为原仓库,比如使用小乌龟做如下修改
1

无校验提交

带上--no-verify

git commit --no-verify -m "修改"

参考资料:
如何撤销 Git 操作?
git提交js文件报错
ERROR on lint:eslint when commit the code into local repositary

Clone this wiki locally