Good day! Learning to use git when developing projects. As the manual says there are 2 ways to create a git repository.

  1. Create an empty repository on github.com and then execute the commands:

    cd "папка на хостинге куда мы хотим разместить git репозиторий" git clone "адрес репозитория на github.com" 

    There are no problems with this method, but sometimes you need to create a repository with existing source code. That is, I lived the code, and then we decided to work on it with a team, we should put it in git.

  2. We fall into the folder with the code on the hosting and execute a number of commands:

    1. git init - initialize the git repository
    2. git add . - we index files in a directory (the starting point from where git will start tracking changes)
    3. git commit -m "Комментарий к коммиту" - Make a commit of previously collected (indexed) files
    4. git remote add origin https://github.com/ИМЯ_ПОЛЬЗОВАТЕЛЯ/НАЗВАНИЕ_ПРОЕКТА.git - as I understand it, we create a repository on github.com
    5. git push -u origin master - well, finally send our files to github.com
  3. Next, the system asks to specify the username and password of the user https://github.com/NAME_ENER .

And I got this error:

error: The requested URL returned error: 403 while accessing

https://github.com/maler1988/testgit.git/info/refs

fatal: HTTP request failed

Following the link https://github.com/maler1988/testgit.git/info/refs I found an article that says that git stopped accepting such commands via HTTP protocol (if I understood everything correctly, of course). In foreign forums it is advised to use SSH, then creating a remote repository will look like this:

 git remote set-url origin git@github.com:maler1988/testgit.git 

but it does not say how to send files to the repository later. The git push command does not work, writes an error and asks to use the link to the repository for git push HTTPS:

You can't push to git: //github.com/maler1988/testgit.git

Use https://github.com/maler1988/testgit.git

In general, I am confused in this method. Unravel me, please!

    2 answers 2

    To get started, create a new github repository. You will have a "quick setup" window on the githab. At the top, under this inscription, there is a switch "HTTPS" and "SSH". Select "https".

    Next, if you already have a local git repository, and you want to upload it, follow the instructions in the section

    ... or push an existing repository from the command line

     git remote add origin https://github.com/ИМЯ_ПОЛЬЗОВАТЕЛЯ/ИМЯ_ПРОЕКТА.git git push -u origin master 

    If you just have files that were not under Git, follow the instructions in the section

    ... or create a new repository on the command line

     echo "# ИМЯ_ПРОЕКТА" >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/ИМЯ_ПОЛЬЗОВАТЕЛЯ/ИМЯ_ПРОЕКТА.git git push -u origin master 

    After that, refresh the page on the site, and your files will appear there.

      You have incorrectly specified a link for ssh. It most likely should be of the type git@github.com:maler1988/testgit.git , and you use the nonexistent protocol git: git://github.com/maler1988/testgit.git