通过git把本地代码提交到代码仓库
git init
git remote add origin https://xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master
代码报错
To https://git.xxx.com/shop/shop-client.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.xxx.com/shop/shop-client.git'
我发现是我的代码权限不足,找人帮我开通master权限
首先我们通过git checkout master切换到master分支上,然后通过git merge origin/”个人分支“,把”个人分支“的内容合并到本地master分支,最后git push,把master的内容也提交到了线上.
git checkout – 在git add之前,把工作区的代码用版本库中的代码覆盖掉,注意命令中的–不能
去掉,否则成切换分支的命令了
git reset HEAD 把git add之后,暂存区的内容全部撤销
git reset --hard commitid 把提交到本地仓库中的代码改动进行回退
git reflog 查看HEAD指针的改动日志
git push -f 强制推送本地仓库代码到远程仓库
git diff HEAD – 查看工作区file文件和仓库中该文件最新版本的代码有什么区别