Problems with push an existing repository from the command line

Hi everybody!

Well, the most part of the problem is in the title. I follow up the instruction from YouTube video call “Lesson Supplement Getting Started with Git and GitHub” (Lesson Supplement Getting Started with Git and GitHub - YouTube) The Window’s version.

One thing I found different was in the video says: git remote add origin LINK git push -u origin main

And when I went to GitHub, I have the following code: git remote add origin LINK git branch -M main git push -u origin main

What was “git branch -M main” does?

Finally, it’s suppose that they ask me my user account and my password but nothing happens.

Any kind of help?

Thank you! Have a nice day!

Always follow GitHub instructions to push a repo for simplicity.

This is related to creating a new branch if I am not mistaken.

Hi @eugenegoh !

Thank for your reply. But, where I can find GitHub instructions?

Once you created a new repository on GitHub, there are a lists of instructions you should follow that is provided by GitHub. For more info check this out.

I follow all the steps but still nothing happens when I push. What should I do?
Here it’s all

Also, I don’t know why I have “git branch -M main”. Of course it’s a new branch, but why? Anywhere mention that. And what “-M” means?

Finally, when I try to close my git I have this message

Captura 3

The quickest and easiest way to find such information ia via git itself. Using git branch --help should output numerous lines of the manual pages which explain all the possible options and flags available for git branch. There are lots of options for viewing manuals man git-branch such as paging tools, passing output to text searches like grep git-branch --help | grep -e "-M" or opening them in your browser. Have a look into what suits you as you’ll use manuals frequently if you make use of the command line.

To save you the trouble this time around using -M should rename your current branch to the given target name (even if a branch with that name exists). From the manuals-

With a -m or -M option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch renaming. If <newbranch> exists, -M must be used to force the rename to happen.

You can view the name of the current branch with git branch on its own (your current branch would have an asterisk next to its name).

I’m not 100% sure why the process hangs on the next step though. I’d have thought it should be prompting you for your git login details at that point to authorise your https push. Something seems to be wrong in this instance. I have seen several similar queries in the last few weeks that all seem to be: windows, git bash, git push issues.

This could be an issue with git, with some form of windows authentication tool or a very small chance (I doubt this one) the bug is with gitbash. I’d highly suggest a web search for those terms or very similar- “windows gitbash push hangs” (limited to last month or two) to see if you can find a known issue. If you find a solution then please share it as I think others have been caught out by this recently.

If you cannot find a solution I think you could look into using ssh authentication instead of https or you could try using a different CLI such as powershell or cmd to see if that is successful instead.

1 Like

The solution (at least for me)

To be clear with the solution, it’s important to define some issues:

  • I use Windows 10
  • I use GitBash (v. 2.32)
  • I try pushing with HTTPS URL

After two days searching, I found there is an issue, when pushing with HTTPS URL, with Git 2.32 (June 2021). To summarize, when you write git push -u origin main and press ENTER nothing happen. It freezes.

What I did was:

  1. Uninstall GitBash

  2. Remove Git folder in C:/Programs o wherever you have installed (I don’t know why it is still there with some elements, so check this)

  3. Restart your PC

  4. Install again GitBash v2.32 but HERE IS THE MAIN POINT, you have to pay attention to Choose a credential helper. Here as default Git Credential Manager Core (NEW) is selected, but I select Git Credential Manager (DEPRECATED) and finish the installation.

  5. I repeat everthing again from Try it Out! Set Up with Git and Github (Eg.: set my, my

  6. And finally, I can do it by myself. I have my first GitHub repository, linked to my local repository.


  • Before I found a solution, I tried with SSH mode. And it seems to be working, but I didn’t configure it. So I stucked there because I need a key and other things which is unknown for me.
  • Despite the fact that it works, GitHub notice me that the basic authentication using a password to Git is deprecated an will soon no longer work. So, it’s a solution for now but not forever.

Thank you so much if you are still reading, and I apologize for my english. Have a nice day and keep coding! :smirk:


So Ive been having this problem and finally figured it out. do not past the code from github type out the code and on the 2nd and 3rd line change main to master. I did that and it worked