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)