Commands to upload files to github

Asked

Viewed 21,697 times

5

I’m trying to upload files to Github. I already created the directory and in Github created the account.

I cannot establish a connection to Github when I enter the folder containing the file I want to host and type these codes below:

git init
git add --all
git commit -m 'Teste de github'
git remote add origin [email protected]:usuario/repositoriogithub.git
git push origin master

The last two commands give error because they cannot establish a connection with the server.

Possibly it must be because of ssh key that I didn’t set up in the installation because I don’t even know where this one is Keys. My operating system is Windows XP SP3, you know where this ssh key is and how to set up on the website and Windows?

Note: I already have the repository created, but I can’t send my files to Github.

  • 1

    Silly question, but you changed usuario by your user and repositoriogithub.git by your repository? .__.

  • boba né rsrs, I’ve done it and it doesn’t work.

  • 1

    Already took a look here: https://help.github.com/articles/generating-ssh-keys/#Platform-windows Tip: If you have GitHub for Windows installed, you can use it to clone repositories and not deal with SSH keys. It also comes with the Git Bash tool, which is the preferred way of running git commands on Windows.

  • I couldn’t even get them to help me. the error when I type this command: git remote add origin [email protected]:ktinho456/server.git is fatal: remoter origin already exitis. and when I type that code git push origin master; da the following error; fatall remote error: ktinho456/:ktinho456/server.git is no a Valid repositori

  • 1

    Already tried to clone your repository, put the files you need there and then commit and make push?

  • but no function can’t get by fileilla but there is no way to start the file I want example folder/a/srver.js when I try to url error that openshift.

Show 1 more comment

1 answer

6

If the repository already exists it is easier to use the git clone

git clone [email protected]:usuario/repositoriogithub.git

Done. Make the necessary changes. To upload the files you need to do the following:

git add *
git commit -m 'Sua mensagem de commit'
git push -u origin master

Ready.

  • 3

    It’s very important to explain git add more. Before the commit, we need to use git add to include certain files in the index. After that we use commit and push.

  • 1

    @Edgarmunizberlinck truth =), was not aware of this information. Thank you for your contribution.

  • I’m doing it from the terminal in Ubuntu, only it always comes up (it appears after I type (git push -u origin master): ! [Rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/usuario/repo.git' tip: Updates Were Rejected because the remote contains work that you do tip: not have locally. This is usually caused by Another Repository pushing tip: to the same ref. You may want to first Integrate the remote changes tip: (e.g., 'git pull ...') before pushing Again. tip: See the 'Note about fast-forwards' in 'git push --help' for Details.

  • @Edgarmunizberlinck Do you know what it is? I think it must be a very silly thing, but I don’t understand it.

  • @Marciellioliveira According to what you posted you are trying to upload an outdated version of your sources. You need to give a git pull before giving a git commit and git push -u origin master. You may have to resolve conflicts. When all is resolved you can upload the sources normally.

  • @Marciellioliveira I edited the answer. See if it helps you.

Show 1 more comment

Browser other questions tagged

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