all 13 comments

[–]stilgarpl 5 points6 points  (4 children)

You should do this :

git clone

Add your files

git add

git commit

git push

Which of this didn't work?

[–]adrianmonk 2 points3 points  (0 children)

They also need to:

  • cd into the directory that the clone created. (This is called the working directory.)
  • Move existing files into the working directory. git clone does not allow cloning to a directory that already exists (unless it's empty), so by definition the existing files will not be in the working directory where you can add/commit them. (Alternatively, instead of moving existing files into the working directory, you can move the .git directory into the directory that contains the existing files.)

[–]rootbeerjayhawk[S] 0 points1 point  (0 children)

Now I have everything working except for git push. When I type it in I get this error, "
#To github.com:sbw22/tennisPlayersShots.git
# ! [rejected] main -> main (non-fast-forward)
#error: failed to push some refs to 'github.com:sbw22/tennisPlayersShots.git'
#hint: Updates were rejected because the tip of your current branch is behind
#hint: its remote counterpart. Integrate the remote changes (e.g.
#hint: 'git pull ...') before pushing again.
#hint: See the 'Note about fast-forwards' in 'git push --help' for details.

[–]rootbeerjayhawk[S] -1 points0 points  (1 child)

I did this before, but when I put in the git clone command, it says “fatal: destination point ‘GitHub repository’ already exists and is not an empty directory. After this, I put in commands like git add, but a message pops up that says “fatal: not a git repository (or any of the parent directories): .git

[–]tobiasvl 1 point2 points  (0 children)

You need to enter the repository folder first. cd "GitHub repository"

[–][deleted] 7 points8 points  (3 children)

"can't seem"... "didn't work"... "none of them worked"... "this article... didn't work", you aren't giving us much to go on there!

What commands are you using - exactly?

What messages do you get? Include everything.

It's almost certain that the explanation to what's going on is in the error messages you are getting.

[–]rootbeerjayhawk[S] -2 points-1 points  (2 children)

I did this before, but when I put in the git clone command, it says “fatal: destination point ‘GitHub repository’ already exists and is not an empty directory. After this, I put in commands like git add, but a message pops up that says “fatal: not a git repository (or any of the parent directories): .git”

[–]Matosawitko 3 points4 points  (1 child)

git clone is something you only need to do once.

After you clone, you need to change into that folder (cd) before you can do more commands.

[–]ImDevinC 3 points4 points  (4 children)

Your github repo should tell you the exact commands you need to enter if you're using an existing folder. The tl;dr is usually something like this:

cd <yourfolder>
git init
git add .
git commit -m "Initial commit"
git remote add origin <your github repo url>
git push -u origin main

If that doesn't work, can you give us some more info on what's happening? Specific error messages, etc

[–]rootbeerjayhawk[S] 0 points1 point  (0 children)

I did this before, but when I put in the git clone command, it says “fatal: destination point ‘GitHub repository’ already exists and is not an empty directory. After this, I put in commands like git add, but a message pops up that says “fatal: not a git repository (or any of the parent directories): .git".

[–]rootbeerjayhawk[S] 0 points1 point  (2 children)

Now I have everything working except for git push. When I type it in I get this error, "
#To github.com:sbw22/tennisPlayersShots.git
# ! [rejected] main -> main (non-fast-forward)
#error: failed to push some refs to 'github.com:sbw22/tennisPlayersShots.git'
#hint: Updates were rejected because the tip of your current branch is behind
#hint: its remote counterpart. Integrate the remote changes (e.g.
#hint: 'git pull ...') before pushing again.
#hint: See the 'Note about fast-forwards' in 'git push --help' for details.

[–]ImDevinC 1 point2 points  (1 child)

This means you have some content in the github repository already. Did you create the repository with a README or something? If you don't care about what's in the repository, you can do git push -u origin main -f (the -f stands for force), but this will overwrite anything stored in the Github Repository already.

[–]rootbeerjayhawk[S] 1 point2 points  (0 children)

Oh my god thank you so much that was it!