git diff 查看编辑前后对比
git status 查看状态
git add ./ 添加gitlab修改的部分
git commit -m "这里可以填写为什么要修改内容"
错误:Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes
(e.g., git pull ...) before pushing again.
➜ hybris-b2b git:(develop) git push origin develop 该修改的部分push 到分支(develop)
To gitlab.devops.esolution.services:hybris/hybris-b2b.git
! [rejected] develop -> develop (fetch first)
error: failed to push some refs to git@gitlab.devops.esolution.services:hybris/hybris-b2b.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 log查看刚刚提交的id,并记录下来
➜ hybris-b2b git:(develop) git log
git reset --hard HEAD 将工作区暂存取和HEAD 保存一致
➜ hybris-b2b git:(develop) git reset --hard HEAD~1 (暂存工作区并取刚刚查看git log从上往下第二条commit的分支)
HEAD is now at b2ee2539 Merge branch feature/ILM-1682_Update-email-content into develop
➜ hybris-b2b git:(develop) git pull origin develop (同步远程的分支)
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 12 (delta 7), reused 12 (delta 7), pack-reused 0
Unpacking objects: 100% (12/12), done.
From gitlab.devops.esolution.services:hybris/hybris-b2b
* branch develop -> FETCH_HEAD
+ b2ee2539...4e96473f develop -> origin/develop (forced update)
CONFLICT (modify/delete): configurations/p01/local.properties deleted in HEAD and modified in 4e96473fac6dcca9e2b00954cd93d4436b9512e7. Version 4e96473fac6dcca9e2b00954cd93d4436b9512e7 of configurations/p01/local.properties left in tree.
Removing bin/custom/testodss/testsrc/de/testo/dss/interceptor/DssSurveyValidateInterceptorTest.java
Removing bin/custom/testodss/src/de/testo/dss/interceptor/DssSurveyValidateInterceptor.java
Automatic merge failed; fix conflicts and then commit the result.
这时需要再向前取比如30条? 然后再同步看看是否正常
➜ hybris-b2b git:(develop) ✗
➜ hybris-b2b git:(develop) ✗ git reset --hard HEAD~30
HEAD is now at d31dd664 Merge branch feature-ILM-1554_generate-new-page-for-each-section into develop
➜ hybris-b2b git:(develop) git pull origin develop
......................................
可以看到同步修改的内容 .
➜ hybris-b2b git:(develop) git status
On branch develop
Your branch is up to date with origin/develop.
nothing to commit, working tree clean
➜ hybris-b2b git:(develop) git cherry-pick a133a35 #捡起之前的记录的id,可以只敲前面5-8个字符
[develop c4f0e127] update smtp users key
Date: Tue Nov 23 11:37:32 2021 +0800
2 files changed, 4 insertions(+), 4 deletions(-)
➜ hybris-b2b git:(develop)
➜ hybris-b2b git:(develop) git log
➜ hybris-b2b git:(develop) git status
On branch develop
Your branch is ahead of origin/develop by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
➜ hybris-b2b git:(develop) git diff
➜ hybris-b2b git:(develop) git remote -v
origin git@gitlab.devops.esolution.services:hybris/hybris-b2b.git (fetch)
origin git@gitlab.devops.esolution.services:hybris/hybris-b2b.git (push)
➜ hybris-b2b git:(develop) git push #然后再使用git push 提交.
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.52 KiB | 1.52 MiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote: https://gitlab.devops.esolution.services/hybris/hybris-b2b/-/merge_requests/new?merge_request%5Bsource_branch%5D=develop
remote:
To gitlab.devops.esolution.services:hybris/hybris-b2b.git
4e96473f..c4f0e127 develop -> develop
➜ hybris-b2b git:(develop)