Getting Started with Git and Github Mac

Hi everyone,

I was in the process of setting up Git and GitHub to link them to a CodeAcademy Project for the first time using this video for Mac:

Everything was working fine, but when I got to one of the last steps:

…or push an existing repository from the command line

git remote add origin git push -u origin master

and copied and pasted the code into Terminal, I received this error message:

fatal: not a git repository (or any of the parent directories): .git

I tried closing and opening Terminal but still receive the same error message.

setting up the remote and pushing in one go? Seems ambitious.

Anyway, did you create a repository in your project as well? You need to create a repository before you can add a remote source.

I have set up the repository. How do I add in the HTML and CSS code from my project onto the repository?

where? On github or on your local machine? You should do both, and then set the github repository as remote in your local git repo.

I’ve done both, I’ve entered this code in Terminal:

Jeanines-MBP:my-project jeaninewilson$ git remote add origin

Jeanines-MBP:my-project jeaninewilson$ git remote -v

origin (fetch)

origin (link hidden) (push)

Jeanines-MBP:my-project jeaninewilson$

How do I now link my work so that it shows up in GitHub?

so the link is established? Then you can do a commit and a push

I think so; I can see the “Readme.txt” on Github. Do I need to save the project onto my machine first (and if so in what format) to do a commit and push? I take it I can’t copy the HTML code into Terminal.

Sorry for all the questions, I’m totally new to this!

then you might need to do pull first. Given github won’t allow you to do a push if there a files on github which aren’t merged with your local version of the project

What do you mean format? What do you think git is and does? I am trying to see where you are struggling.

I see; how do I do a pull?

I mean do I need to save my work as a .html file on my machine. My understanding (from the video I originally linked to) is that I should be able to have my work linked on GitHub and I can then share that link to get feedback on my projects

have you consult the documentation? A google search like: git pull, should help you massively.

Good question. I know the answer, but what do you think? :slight_smile:

here is the answer, but take some time to think about the question before viewing this: the answer is: yes

But if that is what you are after, why not use dropbox? Or google drive? Or one of the other million file sharing services. What is different about git and github? (git and github are not the same thing)

Understanding the tools you are working with is very important. Of course i could spoon feed you all the answers, but i am not going to. Because i want you to ask the right questions. And act upon these questions. Search the internet

Thanks for your help; I have searched but I find the guides very difficult to understand, and now I am also getting an error that the repository cannot be found, although I know one has been set up.

I was following the advice here on Code Academy to share my project: Build your Own Cheatsheet Challenge Project (HTML, CSS)

I feel like maybe I should just come back to this another time

Maybe you should search for a tutorial then? There are plenty

but you didn’t answer my questions?

Which question? About git and github being different?

It’s different because it allows collaboration on code, without the danger of overwriting someone else’s work…

git is version control, you can overwrite someones code, but you can also revert it

github is just the central hub of the version control system.

Link to my cheatsheet