I have three branches in my GitLab
- Main
- ppp7
- ppp7-master
ppp7---> ppp7-master---> main
every day I'm pushing my new code into ppp7 branch.if code is running fine in ppp7 branch, i create new merge request to ppp7-master branch.until here all three branches are have same code only. whats happen yesterday i pushed a wrong code into ppp7 branch.after i merge that ppp7 code into other two branches.but that code failing on all environment. so here i reset ppp7 branch code to previous commit using below comments.
$ git reset --hard 725bb8011bbb2535053feffd441f01d3059fea56
HEAD is now at 725bb80 Update emp.sql
$ git add .
$ git commit -m "where condition removed"
On branch ppp7
Your branch is behind 'origin/ppp7' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
$ git push -f origin ppp7
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for ppp7, visit:
2cb0310...725bb80 ppp7 -> ppp7 (forced update)
now my ppp7 branch have working code, other two branches have wrong code. so i'm creating new merge request to ppp7-master. but I'm cant merge gitlab showing "There are no commits yet." There are no commits yet why I'm cant merge both branches have different code.also when i compare both branches its showing "Showing with 0 additions and 0 deletions". how its possible both branches have different code.
I'm needed to merge new reset code into ppp7-master and why this error showing.
CodePudding user response:
You cannot use Pull/Merge Request functionality to update a branch with a reset. Pull/Merge Requests can only add new commits to a branch; you can't remove commits. Instead you have two options:
- Force push all of the branches that need to be reset.
- Use
git revert
instead ofgit reset
. In Git, "revert" will create a new commit that effectively undoes the changes of a specific commit (or multiple commits if undoing a merge commit).
CodePudding user response:
Below one working for me.
git checkout 725bb8 .
git commit -m "rollback to 725bb8 "
git push origin ppp7
now my working code with new commit.Now i able to create a merge request with ppp7-master.
when i use this comment
- no need to use force push
- no need for reset and revert comment