• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

git push command conflicts with master and main

When I run git push -u origin main on the terminal, it says error: src refspec main does not match any.

But when I run git push -u origin master, it works correctly and it creates another master branch in the repo along with the default main branch and the total branches will be 2.

At this point, I can't do a PR to merge the master to the main and the error message is there's no diff between master and main branches.

Can anyone explain this condition and give me a working solution? Your support will be highly appreciated.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]

I'm pretty sure you'd like a simple formula, do X then Y and it will all work. Unfortunately we can't give you this without more information from you. At the end, I'll suggest a few possibilities, but you must inspect both your commits, and the commits found in the repository over on GitHub.

What's going wrong

The ultimate problem here is that Git is not about branches. Git is all about commits. Branch names do matter, because branch names help us—and Git—find the commits. But it's really the commits that matter. The branch names only matter for finding the commits; after that, the names stop being important—which is why you're free to change them at any time.

The commits themselves are numbered. Those commit numbers, or hash IDs, are the way Git really finds the commits. If you have the number, that's all you really need: give that to Git and Git will find the commit, if you have it. The problem with the numbers is that they're incomprehensible and impossible for humans to deal with. For instance, 2283e0e9af55689215afa39c03beb2315ce18e83 is the hash ID for a commit in the Git repository for Git. Nobody wants to remember this! see demo

  • 0
Reply Report

It sounds like your local branch is called master, whereas the remote branch is called main. You have two options:

  • Rename your local branch:

    git checkout master git branch -m main git push -u origin main 
  • Push your local branch to a differently named remote branch:

    git push -u origin master:main 
  • 0
Reply Report

It wasn't so hard to perform this action actually. What I found was when we initialize a new GitHub project, it automatically creates the main breach as the default branch.

Then we can push our existing project to GitHub using the below commands.

git init git add  git commit -m "msg" git remote add origin  

Next, before moving to the git push command, let's run git branch command to check available branches. git branch shows the local branches while git branch -r shows the remote branches.

Here's my output.

[email protected] test_bmi_app % git branch * master [email protected] test_bmi_app % git branch -r 

You can see there's no output for git branch -r command yet. But it shows the master as the local branch.

Then we need to run the below command to move master to main

git branch -m master main 

Then you can run the git push command along with the -f flag as below.

git push -u -f origin main 

Then it will push your changes to the remote main branch and you can verify it by going to your repo in GitHub.

Then you can issue the below commands to verify and this works pretty well.

git branch git branch -r 


git branch -a 
  • 0
Reply Report