I created an
editor project by
angular, I want to push it in
githup, I followed the following steps (I executed the following
git init git add . git commit -m "push editor project"
all this in
I create a
I create an "editorangular" repository in branch main.
I executed the commands:
git remote add origin master [email protected]:najib132/editorangular.git git remote -v
(it gives me two links:
origin [email protected]:najib132/editorangular.git (fetch) origin [email protected]:najib132/editorangular.git (push)
when i executed command
git push -u origin main
it gives me error:
$ git push -u origin main error: src refspec main does not match any error: failed to push some refs to 'github.com:najib132/editorangular.git'
then I execute command:
git push -u origin master
it creates a
in github branch
main it not from my project, and when i change
branch to master i find my
so I want to
merge between these two remote branchs
main, or push my project directly to the default branch
You have two options:
- Merge locally and push
- Pull request on the remote
Option 1: Merge locally and Push
on your command line while on the master branch, you can do the following commands:
git checkout main
if that fails saying the main branch doesn’t exist or something, then fetch it from the remote
and check it out
git checkout origin/main
This will put you on a detached branch, go ahead and attach it locally.
git checkout -b main
Now that you are on the
main branch you can merge your
master branch to your
git merge master
This will merge the
master branch into the
main branch. You might end up with a merge conflict. That is a separate issue is out of the scope of this question in my opinion, but please feel free to search here on stack overflow for similar questions to solve that separate issue. Once you have satisfied the merge and the state of your local
main branch is how you would like it, push it up to the remote.
git push -u origin main
At this point your code will be on the main branch both locally and on the remote, and also on the master branch. You might want to delete your master branch. You have to delete it on both the remote and locally.
To delete the branch on the remote, issue the following command:
git push origin :master
Note the colon (:) before the branch name
To delete the branch locally, issue the following command while on some branch other than the one you are trying to delete
git branch -d master
you might get a warning about it not being synced to the remote, it suggests capitalizing the
-D switch to force it. go ahead and do this if that is the case.
Option 2: Create a pull request on the remote.
Follow the instructions on this page – https://github.com/najib132/editorangular/compare/main…master
Then select which branch you are merging from and into before clicking "Create pull request"
You will have the opportunity to add any additional details you would like here.
Scroll down to the bottom to finalize the merge
Bonus Option: Make master your default branch
Visit the settings for the repository and under the "Branches" menu you can select the default branch. That page can be directly accessed by you at this link – https://github.com/najib132/editorangular/settings/branches
Note: You may still want to clean up your main branch by deleting it both on the remote and locally.
Answered By – Oxymoron