-1
error: failed to push some refs to 'https://github.com/<user-name>/<project-name>.git'

hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint: (e.g. 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Ali Raza
  • 670
  • 5
  • 15
  • https://stackoverflow.com/search?q=%5Bgit%5D+Updates+were+rejected+because+a+pushed+branch+tip+is+behind – phd Aug 11 '21 at 13:11
  • Please be sure to add context to your questions, not just list an error. Say what you're trying to do, what you've tried, etc. – Jeremy L. Apr 22 '22 at 03:34

1 Answers1

1

This is intended to be a comment, I don't have enough reputation to comment.

Can you please elaborate on the question? What are you trying to do? What command do you run before this error message is displayed?

My guess is that you're trying to publish to Github pages using gh-pages, in this case, I can provide two solutions for this:

  1. You could delete the remote and local branch named gh-pages;
  2. You could also pull the remote branch into the local one;

I will describe in a few simple steps how to do it: If you want to delete the remote branch and the local one, head out to the main page of your repository, then at the left side you'll see a dropdown menu with all the branches, you can expand this dropdown and click on view all, heading out to all branches, you'll find a trash icon in the gh-pages branch, go ahead and delete it (but beware, only delete it if its data is not valuable, for instance, a build result). Finally open up your project folder in the terminal and run git branch -d gh-pages.

But if you want to rather pull the remote branch into yours, just do a git checkout gh-pages; git pull; git checkout -, in the last command, dash is an alias for "the previous branch before checking out", this will integrate all the changes that are online in the repository into your local branch.

Overclocked Skid
  • 465
  • 5
  • 12