git clone + ssh 或者 https // 拉取项目
(要么从新打开,要么cd进入项目)
git branch -r // 检查远端分支
git checkout -b xxx // xxx 是分支名称,加了-b就是说如果没有这个分支会新建一个分支
(此时进入这个分支)
git branch --set-upstream-to=origin/xxx xxx // 建立本地对比库
(这里如果提示找不到该分支输 git fetch 会自动刷新检查版本,一般都能解决问题)
git pull origin xxx // 拉取分支远端最新内容
git push origin xxx // push版本 需要先commit
提交:
如果commit被husky或者pre-commit拦下来了:
rm -fr .git/hooks/ // 尤其像编译antdPro的这种巨巨型框架会经常遇到这种
忘记添加至 .gitignore 后的修正:
git rm -r --cached .
git add .
git commit -m 'fix- 修正gitignore
git push xxxxxx
要是不小心把node_modules传上去了
git rm --cached -r xxxxx (这里是要删的东西)
git commit -m "remove directory from remote repository"
git push
关于合并commit
常用的方法,
git rebase -i xxxxxxxx(是版本哈希值
git cherry-pick
回滚的方法 !切记注意会滚的时候commit操作也可能被会滚掉!
git reflog
git reset --hard HEAD@{3}