How to push local folder to Github

Asked

Viewed 21,058 times

2

I would like to push a local repository to my Github. I did the standard procedure for this:

git clone <chave ssh>

Until then everything wonderful, he created a copy of the Gihub repository locally. Inside this repository is a folder with files that I also want to send to the corresponding repository on Github. I did add and commit of the folder and then made a push to the repository on Github, but apparently it only adds the folder and not its files. I navigated to the folder and did the same previous procedure and got the following output:

$ git push origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Any suggestions on how to do the push of those files?

  • When you type git status the files of such directory in green? If they do not appear, you can add them by typing git add diretório/nome_do_arquivo?

  • In this directory, there is the . git folder? So inside there is a file called config. Look in this file and see if you have a remote repository called origin and if you have a branch master. Something else, I always add from the repository root folder and use the add --all. Something else, uploaded the key to github? Take a look at https://github.com/settings/ssh

  • Make sure you clone with your github credentials. It is possible that you have made the clone with the address for anonymous user and do not get write permissions there. Also remember to check if your public key is registered in your github settings.

  • As I see the colleagues above commenting, I deduce that you are initiating versioning using git with github. recommend https://try.github.io/ to practice and improve knowledge about git.

4 answers

6

I had a very similar problem when I started versioning with Git + Github, and this problem occurred when the remote directory was not created for 'origin''.

This requires the following command:

git remote add origin [endereco-do-repositorio]

The git clone guarantees only a copy of the repository. For more information you can access the Help from Github.

1

Only complementing the soaresfelipe response:

git remote add origin <URL> will add the address to your remote Reposorios (which should be sufficient in your case). But, I advise you to use the git add -A in the root folder of your repository after, yes git commit before pushing, because apparently you are not committing all the files.

If in doubt you can use the git log to check which commits have already been made.

  • I did the following: git remote add origin <URL>, then after that take a look at the file. git/config if it appears the tags [remote "origin"] and below the tag [branch "master"]. If that’s all right, add the files you want to send with $git add [files], then commit and then push. Now your files will already be unlocked in gitbhub.

0

Type to check if you have any repositories:

 git remote -v

If yes, something like this will appear:

origin  [email protected]:<seu_usuario>/sua_app.git (fetch)
origin  [email protected]:<seu_usuario>/sua_app.git (push)

If it does not appear and inform q there is no repository you will have to add some. If it is Github:

Click on the icon + > New repository (this is situated in the menu next to your user’s photo).

Then just fill in the data as the name of the repository, if you are going to choose the public or private type. Then Github will be informed what you need, just follow up.

0

This happened because you didn’t link between your local repository and the repository on Github.

Use the command git remote add <apelido> <link-do-repositório-github>, replacing what is between the symbols <>.

It is common to use the nickname by default origin pro remote repository.

To check if the link was correctly created use git remote and git will tell you the name of the remote repository your location is pointing to.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.