-1

I had a repository. I rolled back to the old commit. Now push a new one. And I get this message.

On the master branch Your branch is 10 commits behind “origin / master” and can be rewind ahead. (use "git pull" to update your local branch) nothing to commit, no changes in the working directory

How can I ignore it? Or how to just delete these 10 commits?

unknown
  • 252
  • 3
  • 12
  • 37

1 Answers1

1

if you did a git reset --hard on a local branch and now you want the remote branch to look like you did the same on it, you should your push --force it onto the remote

git push --force some-remote the-branch
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • force option will override the remote branch with local branch. A safer option is the force-with-lease option will ensure you do not override someone else work. https://stackoverflow.com/questions/52823692/git-push-force-with-lease-vs-force – Kevin Grosgojat Jun 19 '19 at 00:34
  • Well... 10 commits are to be _deleted_. If you try with `--force-with-lease`, you will never be able to push the branch without those 10 commits into the remote. – eftshift0 Jun 19 '19 at 00:41
  • --force-with-lease allow you to delete commits. It ensure you'll not overwrite any work on the remote branch if more commits were added to the remote branch (by coworker or what have you). It ensures you do not overwrite someone elses work by force pushing. – Kevin Grosgojat Jun 19 '19 at 00:51
  • So what it checks is that what you have as the remote branch hasn't moved on the remote since your last fetch/pull? – eftshift0 Jun 19 '19 at 01:19