時(shí)刻查看當(dāng)前branch是個(gè)好習(xí)慣。
當(dāng)git add 和 git commit 到錯(cuò)誤分支,需要git reset --soft HEAD^補(bǔ)救。
-------------------------------------------------------------------------------------------
當(dāng)本地分支在git push origin dev-xiaoan 被拒絕時(shí),
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,修改已經(jīng)更新到遠(yuǎn)端。
-------------------------------------------------------------------------------------------------------------------
git 撤回提交遠(yuǎn)端的版本
1. git log? 查找commit的版本號(hào)
2. git reset --hard <版本號(hào)>? , 撤回到我們需要回退的版本
3. git push origin master? --force? ?重新提交