Answer a question

P.S: Please note that i have read almost all other related questions about this but it still not working at all.

I have the following issue on master branch:

git status

On branch master
Your branch is ahead of 'origin/master' by 5 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

after reading most of the articles here about this case and asking the company i work for, i am not allowed to:

rebase

or use

git fetch origin git reset --hard origin/master

so i tried:

git fetch origin
git pull

but i have the same result after doing git status

What should i do to fix my local master branch exactly?

my goal:

  • not to push because i am on master

  • get rid of the current commit without affecting master branch

Answers

To roll back 5 commits locally to keep in sync with remote master branch, you can do this:

git reset --hard HEAD~5

Or run git log and reset to the HEAD commit of origin/master

git reset --hard <commit id>

You could also just reset to origin/master

git reset --hard origin/master
Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐