Home > database >  Git lab showing "There are no commits yet" after my git reset?
Git lab showing "There are no commits yet" after my git reset?

Time:12-11

I have three branches in my GitLab

  1. Main
  2. ppp7
  3. 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.

  1. when comparing ppp7 branch with ppp7-master
  2. when i comparing ppp7-master with ppp7

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:

  1. Force push all of the branches that need to be reset.
  2. Use git revert instead of git 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

  1. no need to use force push
  2. no need for reset and revert comment
  • Related