Search code examples
gitgitlabgit-bashgit-checkoutgit-revert

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


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.


Solution

  • 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