Why I'm having problems pushing my first repo? - github

I'm trying to push my first repo to github but I got this error
git branch -M main
fatal: Invalid branch name: 'HEAD'
Could someone help me to fix the problem

git branch is a local command which does not push anything.
To avoid any issue, the easiest approach is:
git clone https://github.com/<me>/<myRepo>
cd <myRepo>
# report the work you did in your previous repo
git add .
git commit -m "First commit"
git push -u origin main

Related

Not able to add remote repository

I want to push changes from my local repository to my github repo. I start with the commands giving from github quickstep:
git init
git add .
git commit -m "first commit"
and then
$ git add origin https://github.com/Svein-Tore/forrigling.git
fatal: pathspec 'origin' did not match any files
Any suggestions to what can be wrong?
You've to use git remote add origin https://github.com/Svein-Tore/forrigling.git
When you use git add origin, it tries to add the file 'origin'

Github - How to update my own repository?

I have a repository in my Github, and I cloned it on my desktop. Then I did some work in the folder. How do I commit those changes to my repository?
below code is right, but don't forget to add remote address to key "origin".
git remote add origin <YOUR_REPOSITORY_PATH>
git add .
git commit -m 'some change'
git push -u origin master
-u – sets repo branch as defaults, so then you can push, just git push
May
git add .
git commit -m "my changes"
git push origin master

How to push on my development branch on Github

I get an issue when I try to push on my development branch on Github. Actually, I forked the microscopejs repository to update some files...
Command :
git clone https://github.com/tonymx227/microscopejs.git
git add remote upstream https://github.com/tonymx227/microscopejs.git
git fetch upstream
// I updated some files using Sublime Text 2 here
git add . -A
git commit -m 'test'
git push origin development
Issue :
error: src refspec development does not match any.
error: failed to push some refs to 'https://github.com/tonymx227/microscopejs.git'
You haven't create a local development branch.
You only have the remote tracking branch origin/development after your clone.
Do first a:
git checkout -b development origin/development
Then:
git add . -A
git commit -m 'test'
git push -u origin development
Note: you don't need the git remote add upstream step.

how to code commit on github using MINGW32?

i created a repositories on github.
now i want to put my some code there can anybody tell me how to do this and how to commit code.
i tried using this lines
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Dany001/myrepo.git
git push -u origin master
please short out my problem
Thanks

fatal error in git hub when pushing in branch

I want to push to a branch which is not master. That is what I did:
git init
git add .
git commit -m "first"
git push origin second (second is the name of a branch) but it say
fatal: origin does not appear to be a git repository.
fatal: could not read from remote repository.
Please sure you have the correct access rights and the repository exists.
Last night I could do that and in the morning suddenly it does not recognize my branch! it does not show my branch when I do git branch, it only shows a master branch. But why I experience this problem sometimes?
Thanks :)
First, make sure you are in the right branch: if git branch doesn't list 'second', you can create it:
git checkout -b second
Actually "second" branch exists and I can see it on the github site
Then:
git checkout -b second --track origin/second
(a git fetch origin might be in order first)
Then, make sure the remote 'origin' exists:
git remote -v
And then, push and set origin/second as upstream branch of your local branch second.
git push -u origin second
(See "Why do I need to explicitly push a new branch?" for more)
try
git pull origin master
before
git push origin master
I had the same error and it worked for me.