时刻查看当前branch是个好习惯。
当git add 和 git commit 到错误分支,需要git reset --soft HEAD^补救。
-------------------------------------------------------------------------------------------
当本地分支在git push origin dev-xiaoan 被拒绝时,
error: failed to push some refs ...
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
如果git reset HEAD不起作用,尝试
git pull origin dev-xiaoan
git push origin dev-xiaoan
浏览器打开Git查看commit,修改已经更新到远端。
-------------------------------------------------------------------------------------------------------------------
git 撤回提交远端的版本
1. git log 查找commit的版本号
2. git reset --hard <版本号> , 撤回到我们需要回退的版本
3. git push origin master --force 重新提交