-2

I have been trying to create a repo to github through git, but I couldn't do it, these are the steps I did:

git init
git add .
git commit
git push

and this is the message I get:

fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

when I use the command I get nothing:

 git push --set-upstream origin main

another thing, sorry if it sounded stupid but I really want to understand, the first time I configured git on my PC it connected with github, but when I upgraded my OS even if I tried to configured it again I couldn't, I configured my username but it didn't appears on the git window

Mai Osama
  • 1
  • 3
  • Do you have an `origin` remote? You did not show us any proof that you created one. – matt Jun 21 '21 at 22:59
  • 1
    Also just in case, please see https://stackoverflow.com/questions/68057254/after-git-push-u-origin-main-command-git-bash-is-not-requesting-any-authentic – matt Jun 21 '21 at 23:07
  • I am new in this so if my answer is clear or it is not what you meant, please clarify it to me.I have been trying to add origin, if it is done on my terminal it is not connected with github in any way, I cant create or push anything to github, I use the upload files to github. – Mai Osama Jun 22 '21 at 11:58

1 Answers1

0

Then the issue is that you have not configured git to always create new branches on the remote from local ones.

The permanent fix if you always want to just create that new branch on the remote to mirror and track your local branch is:

git config --global push.default current
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
  • It could be possible that your url is not set correctly. Here it would help if you would share your .git/config – Matthias Mulser Jun 21 '21 at 22:22
  • .git/config: line 1: [core]: command not found .git/config: line 2: repositoryformatversion: command not found .git/config: line 3: filemode: command not found .git/config: line 4: bare: command not found .git/config: line 5: logallrefupdates: command not found .git/config: line 6: symlinks: command not found .git/config: line 7: ignorecase: command not found – Mai Osama Jun 22 '21 at 11:38