[Git]commit错误分支|分支上传被拒

时刻查看当前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   重新提交

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 首先确定电脑安装了git 输入git 会产生提示: 如果没有安装,那么就网上搜索下载完成安装. 可以使用命令行安装...
    彗星来的那一夜阅读 863评论 0 0
  • git 使用笔记 git原理: 文件(blob)对象,树(tree)对象,提交(commit)对象 tree对象 ...
    神刀阅读 3,808评论 0 10
  • 学习笔记,非原创。谢谢 Git鼓励大量使用分支: 创建与合并分支 :查看分支:git branch创建分支:git...
    Rising_life阅读 860评论 0 1
  • 首先确定电脑安装了git 输入git会产生提示: 如果没有安装,那么就网上搜索下载完成安装. 可以使用命令行安装,...
    元宇宙协会阅读 4,502评论 1 9
  • 2016.12.4 虽然14年开发第一个项目时就已经接触了git,当时xcode已经开始支持git,在github...
    張小明阅读 421评论 1 0