在代码push提交时,出现问题
error: failed to push some refs to 'https://xxx@xxx/SA/SW.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first 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 checkout -b temp
切换到该临时分支后查看提交记录
git log -2
commit 0b9bca2ebc038808d13e7a034d5e7a32646b129c (HEAD -> temp, dev)
Author: xxx <xxx@cvte.com>
Date: Fri Jul 28 11:54:45 2017 +0800
[add]增加注释信息
commit 679d26d5d16fb2d65ea6f10003fa1e764f9dc51d (origin/master, origin/dev, master)
Author: xxx <xxx@cvte.com>
Date: Thu Jul 27 22:58:45 2017 +0800
[add]增加md5
切换到dev分支
git checkout dev
回退到log中记录的某个版本
git reset --hard 679d26d5d16fb2d65ea6f10003fa1e764f9dc51d
查看提交记录
git log -2
commit 679d26d5d16fb2d65ea6f10003fa1e764f9dc51d (HEAD -> dev, origin/master, origin/dev, master)
Author: xxx <xxx@cvte.com>
Date: Thu Jul 27 22:58:45 2017 +0800
[add]增加md5
commit 929c269393ebd527af9c1d5fa86a900346332c67
Author: xxx <xxx@cvte.com>
Date: Thu Jul 27 21:42:51 2017 +0800
[add]增减keyWordFunction
pull下拉dev分支代码
git pull origin dev
将已经提交的commit, 从一个分支放到当前这个分支
git cherry-pick 0b9bca2ebc038808d13e7a034d5e7a32646b129c
push上传代码
git push origin dev
强制删除临时分支
git branch -D temp
搞定