user1706538
user1706538

Reputation: 641

GitHub "Failed to publish this branch" error on Windows

I'm new to Git, and I just downloaded it yesterday. As a test for my first online (not local) repository, I committed a useless text file and then hit publish. After a short while, I got this very non-descriptive error:

Enter image description here

So I know that I can't publish to this branch. There's only one and it's the master branch. Is there any further information on what might be causing this error?

As a side note, my partner has successfully uploaded files to the same repository, but I haven't gotten any sort of indication that this has happened. Does this mean I'm not connected to the repository properly in some way? I was the one who set it up!

Upvotes: 47

Views: 42266

Answers (11)

Ivy Growing
Ivy Growing

Reputation: 3294

I had this error since I forgot to add a remote repository link in the GitHub Desktop. Once I added the correct repository link, everything worked.

Upvotes: 1

Vincent
Vincent

Reputation: 2169

I got this error because I already had created a repository with the same name on GitHub, and then created it locally and tried to commit it. The solution was to delete it from GitHub, then commit it from the local client. Now they're in sync.

Upvotes: 0

Robin Raju
Robin Raju

Reputation: 1325

I too had the same problem while publishing my GitHub page. I solved it in the following way.

git push

I got the error message here. Then I made a pull request

git pull

After this I made the push again

git push

Here I got the solution.

Note: I use GitHub for Windows. And I finally published the page using it

Upvotes: 0

Has AlTaiar
Has AlTaiar

Reputation: 4152

I had the same issue as mentioned here, but none of the previous solutions helped. Then I found this answer which talks about Proxy settings, which is exactly why GitHub was failing to commit on my machine.

To set up your proxy settings, you just need to use this command:

git config --global http.proxy http[s]://userName:password@proxyaddress:port

Upvotes: 3

andylei
andylei

Reputation: 11

Maybe you just forget type something to the Description area when you commit your files. Someone like me only type the summery. So make sure you have fill in the Summary and Description when you commit.

Just type something to the Description textarea when committing. Then I published successfully.

What I do:

  1. Go to the folder of your repository in Windows Explorer
  2. Delete the file your want to publish. And recreate it.
  3. Open GitHub for Windows and click on your repository. Then you will find Uncommitted changes on the left side.
  4. Type your Summary
  5. Type your Description (the most important step!)
  6. Commit to master
  7. Hit Publish and you should be successful.

This is my first answer. so i have no 10 reputation to post an image......hope help you.

Upvotes: 1

Dennis Holmer
Dennis Holmer

Reputation: 134

To fix it, open a command prompt in the repository. For example, by pressing the cog in the top right in the repo view and selecting "open a shell here".

  • In the command prompt, type git push --set-upstream origin master

  • Either this will work, or it will say ! [rejected] master -> master (fetch first)

  • If this happens, type git pull origin master (add --rebase if you like)

In GitHub, the Publish button might still be visible instead of the sync button. If this is the case, simply restart GitHub.

This resets the default remote branch for your local branch to master.

Upvotes: 1

Mr_Green
Mr_Green

Reputation: 41840

In Windows, right click on your repository → click on Open a shell here.

You will see a command prompt.

Type git push in it. (been aware after seeing SimonBoudrias comment)

The command prompt will suggest you to type some other command or shows an error.

If the command prompt suggest you to type something else, then type that. It will work.
If the command prompt shows an error, then please post the detailed error here.

Information: You might want to check this app

Upvotes: 37

PapaHotelPapa
PapaHotelPapa

Reputation: 697

I was getting that error because I hadn't properly configured my name and email. On the page where you do that (in the native app, at least), you'll see that the page opens with your name and email already filled in but that doesn't mean that they're saved as settings. In order to save them, you have to press the check mark in the bottom left corner of that screen.

Upvotes: 0

Nallebeorn
Nallebeorn

Reputation: 131

Open a shell in your repository. Then type

git push --set-upstream origin master --force

This will upload your local repo to the server no matter what, overwriting if necessary. This should only be done if you're sure nobody else is publishing to your repo at the moment.

Upvotes: 11

Jose Luis Blanco
Jose Luis Blanco

Reputation: 725

Another possibility is a temporary unavailability of GitHub servers.

I'm just having the same problem and confirmed that it's a server issue: https://status.github.com/

Sample screenshot:

GitHub temporarily down

Upvotes: 1

VladimirS
VladimirS

Reputation: 37

Try to commit your changes before publishing. It helps me to solve same problem.

Upvotes: 0

Related Questions